assetlinks.json 中的应用程序链接意图过滤器在 Android 上不起作用

2024-01-03

我的应用程序定义了意图过滤器来处理来自我的网站的 URL(由以下定义)

<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <category android:name="android.intent.category.BROWSABLE"/>
  <data android:host="www.host.com" android:scheme="http"/>
</intent-filter>
<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <category android:name="android.intent.category.BROWSABLE"/>
  <data android:host="www.host.com" android:scheme="https"/>
</intent-filter>

应用程序可以正确检测正确主机的 URL,但会询问用户是否在应用程序或浏览器中打开它们。我尝试使用此处指定的应用程序链接验证:https://developer.android.com/training/app-links/index.html https://developer.android.com/training/app-links/index.html

正如我的服务器日志中所见,安装应用程序时,设备会查询 /well-known/assetlinks.json 并以 200 状态进行响应。使用以下命令测试数字资产文件

https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://<domain1>:<port>&relation=delegate_permission/common.handle_all_urls

API 并没有发现错误。

assetlinks.json 文件中的 SHA256 是使用以下命令获取的

keytool -list -v -keystore my-release-key.keystore 

与应用程序签名相同的 .keystore。

Running adb shell dumpsys package d返回链接验证状态为“询问”,表示验证失败。为什么验证会失败?


对于我们来说,这是 Windows 行结尾!

测试用“”事实证明这是无价的,因为它给了我们一个“无法解析语句列表(无效的 JSON)”错误,导致我们遇到了问题。

提示:最好使用 Android Studio 应用程序链接助手中的“保存文件”按钮,而不是像我们那样进行复制和粘贴 - 这样它会自行生成文件,并保证不会出现此问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

assetlinks.json 中的应用程序链接意图过滤器在 Android 上不起作用 的相关文章

随机推荐