问题是在android 12或更高版本中通过链接打开应用程序。
在较低版本的android上,一切都很好。
当我查看我的“应用程序信息”->时,默认情况下打开“屏幕”。我看到未经批准的链接。
当我打开被支持的网址内部的链接时,通过链接打开应用程序是有效的。
我读过关于在android文档中验证意图过滤器的文章,在我看来一切都很好。
https://developer.android.com/training/app-links/verify-site-associations#add-intent-filters
已经将. https://my.domain.net/.well-known/assetlinks.json内容的.著名/资产链接.known(生成并与https://developers.google.com/digital-asset-links/tools/generator进行了检查)的域
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "my.package.name",
"sha256_cert_fingerprints": ["SHA_256"] }
}]
三次检查我使用的是正确的SHA_256。
还测试了.json是否可以使用“语句列表生成器和测试器”,上面提到的链接。
AndroidManifest.xml内部的意图过滤器
<intent-filter
android:autoVerify="true"
android:label="@string/login_to_app">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="my.domain.net"
android:pathPrefix="/${dynamicVar}/our/application/"
android:scheme="https" />
</intent-filter>
另外,我上传应用程序到play商店只是为了确保这不是SHA证书或play存储相关的问题,但是没有区别。
此外,我检查了我的应用程序包名称,这是正确的内部测试和调试。
我也采取了添加每个组合的应用程序包名称,只是为了确保。
简单地说:通过android 12及更高版本的链接打开应用程序,由于不受支持的web地址而无法工作。
我知道,当我手动检查受支持的web地址时,需要用.众所熟知的/资产链接.known来验证链接,但这不是最终的解决方案。
我不知道我在这里错过了什么。
有人知道我在这里做错了什么吗?
发布于 2022-02-16 09:54:46
什么改变了?
从Android 12开始,他们引入了一种检查受支持的web域的新方法。
android的较低版本保持不变。
在android 12中的验证是如何工作的?
在安装应用程序时,android会向意图链接中的域发送异步请求,以检查.known是否存在并且是否有效。
如何生成assetlinks.json?
我建议使用google为生成该文件提供的工具。它还可以检查assetlinks.json是否存在并正确设置。
发电机:https://developers.google.com/digital-asset-links/tools/generator
哪里能拿到SHA-256表格?
在生成.json文件之后,将其放在域的根中(众所周知/assetlinks.json s.json)。
我建议手动打开它以确保。
https://my.domain.com/.well-known/assetlinks.json
在应用程序中设置意图链接
给你AndroidManifest.xml添加
<!-- Make sure you explicitly set android:autoVerify to "true". -->
<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" />
<!-- If a user clicks on a shared link that uses the "http" scheme, your
app should be able to delegate that traffic to "https". -->
<data android:scheme="http" />
<data android:scheme="https" />
<!-- Include one or more domains that should be verified. -->
<data
android:scheme="https"
android:host="**my.domain.com**"
android:pathPrefix="/test" />
</intent-filter>
手动测试意图链接是否有效:
您可以在模拟器运行时运行此命令,它应该打开应用程序:
adb shell am start -W -a android.intent.action.VIEW -d "https://my.domain.com/test?code=abcde"
手动测试意图链接
adb shell am compat enable 175408749 PACKAGE_NAME
adb shell pm set-app-links --package PACKAGE_NAME 0 all
adb shell pm verify-app-links --re-verify PACKAGE_NAME
运行此命令后,至少要等待一分钟应用程序来验证您的域.。adb shell pm get-app-links PACKAGE_NAME
此命令的输出类似于以下内容:
com.example.pkg:
ID: 01234567-89ab-cdef-0123-456789abcdef
Signatures: [***]
Domain verification state:
my.domain.com: verified
sub.example.com: legacy_failure
example.net: verified
example.org: 1026
在此之后,您的意图链接将在android 12和更低版本上运行。
最终测试,以检查是否正确地设置了所有
运行:
adb shell am start -W -a android.intent.action.VIEW -d "https://my.domain.com/test?code=abcde"
来源:https://developer.android.com/training/app-links/verify-site-associations
发布于 2022-09-28 12:45:43
https://stackoverflow.com/questions/71079961
复制相似问题