You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native中Android Deeplink邀请链接无法跳转至应用问题

Android 应用无法通过自定义邀请链接唤起的解决指南

问题背景

我正在实现邀请功能:用户创建https://myapp_domain/UNIQUE_CODE格式的邀请链接,其他用户打开链接后应自动唤起应用并添加好友。当前问题:Android设备及模拟器中打开链接仅跳转至浏览器,无法唤起应用,但通过adb命令adb shell am start -W -a android.intent.action.VIEW -d "http://dev.0xfire.com/ABC"可正常跳转。Firebase Dynamic Links即将在8月废弃,已完成以下配置:

  • AndroidManifest.xml中添加了对应intent-filter
  • Node.js REST API配置了.well-known/assetlinks.json路由,SHA256证书由本地.android文件夹密钥生成,怀疑证书存在问题但不知如何获取可信密钥

补充信息:使用Android 11模拟器,应用未发布,域名dev.0xfire.com同时作为邀请域名和REST API域名,无www前缀。


核心排查与解决步骤

1. 确认SHA256证书指纹的正确性

本地调试和发布版本使用不同密钥,必须匹配对应指纹:

  • 获取debug密钥指纹(调试场景用):执行命令
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  • 确保.well-known/assetlinks.json中的sha256_cert_fingerprints字段完全匹配上述debug指纹,注意不要有多余空格或大小写错误
  • 若用Android Studio Run按钮安装应用,默认使用debug密钥,必须对应此指纹

2. 检查AndroidManifest.xml的intent-filter配置

确保配置符合Android 11+要求:

<activity
    android:name=".DeepLinkActivity"
    android:exported="true"> <!-- Android 12+强制要求,否则无法接收外部intent -->
    <intent-filter android:autoVerify="true"> <!-- 开启系统自动验证assetlinks.json -->
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- 匹配目标域名及所有子路径 -->
        <data
            android:scheme="https"
            android:host="dev.0xfire.com"
            android:pathPattern="/.*" />
    </intent-filter>
</activity>
  • android:autoVerify="true"是自动唤起应用的关键,缺少则系统不会验证assetlinks配置
  • 确保android:host与邀请域名完全一致(无www前缀)
  • 确保https://dev.0xfire.com/.well-known/assetlinks.json可公开访问(返回200状态码),格式如下:
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.your.app.package", // 替换为你的应用包名
    "sha256_cert_fingerprints": ["你的SHA256指纹"]
  }
}]
  • 可通过Android Studio的App Links Assistant(路径:Tools > App Links Assistant)一键验证配置,它会自动检查assetlinks的正确性

4. 适配Android 11的包可见性限制

Android 11及以上需要在AndroidManifest.xml中添加queries,允许浏览器唤起你的应用:

<queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="https" />
    </intent>
    <!-- 可选:指定常用浏览器包名,确保兼容性 -->
    <package android:name="com.android.chrome" />
    <package android:name="com.google.android.apps.chrome" />
</queries>

5. 测试注意事项

  • 避免直接在浏览器地址栏输入链接测试,建议通过短信、笔记APP点击链接,或用adb命令验证
  • 清除应用的默认链接处理设置:进入应用设置 > 打开方式 > 清除默认值,再重新测试
  • 模拟器需确保系统WebView为最新版本,旧版本可能不支持自动链接验证

内容的提问来源于stack exchange,提问作者Makalei Galkim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 22:52:21