Jak*_*ke_ 4 android json deep-linking applinks android-6.0-marshmallow
我定义我的应用程序链接如下AndroidManifest.xml:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="mysite.com" android:scheme="http"/>
<data android:host="mysite.com" android:scheme="https"/>
<data android:host="www.mysite.com" android:scheme="http"/>
<data android:host="www.mysite.com" android:scheme="https"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
该应用程序正确地检测到来自主机的 URL,但会提示用户是否要在应用程序或浏览器中打开它们,因为验证失败,如 Android 监控控制台所示:
01-17 15:44:28.847 7084-30015/? I/IntentFilterIntentSvc: Verifying IntentFilter. verificationId:2 scheme:"https" hosts:"mysite.com www.mysite.com" package:"com.site.myapp.android.flavor".
01-17 15:44:29.821 7084-30015/? I/IntentFilterIntentSvc: Verification 2 complete. Success:false. Failed hosts:mysite.com,www.mysite.com.
Run Code Online (Sandbox Code Playgroud)
我的 assetlinks.json 文件位于mysite.com/.well-known/assetlinks.json并包含正确的包名称和 SHA256 哈希值。它也可以通过 http 和 https 访问。我已经通过从 APK 中提取 CERT.RSA 文件并使用keytool -printcert -file CERT.RSA
我曾尝试调用https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls以及使用谷歌站点语句列表测试器,并且都返回 OK。
我正在使用运行 Android 7 的 Nexus 设备进行测试。
根据文档,我已经完成了应用程序链接工作所需的一切。还有什么我可以检查的吗?
我的服务器在 Windows 7 上运行 IIS,我已经在 IIS 和 web.config 文件中添加了 application/json 作为 mimetype。会不会因为我使用的是自签名 SSL 证书而失败?
编辑: SingleHostAsyncVerifier 还记录验证失败。(用示例和 SHA 哈希替换 mysite)
01-17 15:44:29.817 7084-30017/? I/SingleHostAsyncVerifier: Verification result: checking for a statement with source a <
a: "https://www.example.com"
>
, relation delegate_permission/common.handle_all_urls, and target b <
a: "com.mypackage.flavor"
b <
a: "(SHA256 hash)"
>
>
--> false.
01-17 15:44:29.820 7084-30016/? I/SingleHostAsyncVerifier: Verification result: checking for a statement with source a <
a: "https://example.com"
>
, relation delegate_permission/common.handle_all_urls, and target b <
a: "com.mypackage.flavor"
b <
a: "(SHA256 hash)"
>
>
--> false.
Run Code Online (Sandbox Code Playgroud)
尽管应用链接文档中未提及,但应用链接要求服务器具有来自公共或受信任证书颁发机构的有效 SSL 证书。自签名证书不起作用。
切换到https://www.thawte.com/颁发的 SSL 证书后,应用链接验证成功完成。