Tho*_*ook 12 android deep-linking
我正在Android上实现应用链接.我们的服务器团队已经托管assetlinks.json
在我们的开发端点上/.well-known/assetlinks.json
.
在我的应用程序清单中,我根据官方文档编写了intent过滤器,如下所示:
<!-- Intent filter for supporting deep linking (referred to as magic login links) -->
<intent-filter
android:autoVerify="true"
tools:ignore="UnusedAttribute">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="@string/app_link_login_host"
android:scheme="https" />
<data
android:host="@string/app_link_login_host"
android:scheme="http" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
现在,我的理解是,当应用程序第一次运行时,Android操作系统将搜索清单对于包含主机/方案对,其中所有的意图过滤器autoVerify=true
和VIEW
行动,并DEFAULT
和BROWSABLE
类别都存在.然后它将转到主机URL并assetlinks.json
从/.well-known/
路径请求文件,并使用此json文件中的SHA哈希和包名称来验证应用程序是否允许接受来自给定主机的深层链接.如果此操作成功,则应将应用程序标记为status: always
与意图过滤器内主机提供的链接相关联.如果失败,那么应用程序将被标记为status: never
主机.
但是,我们的服务器团队已经为登台设置了一个新的端点,他们没有将assetlinks.json
文件上传到/.well-known/
路径(事实上他们根本没有托管它).然而,应用程序仍然可以接受来自清单中指定的主机的链接(由于assetlinks
端点上没有文件而应该验证失败).
这是当我意识到也许dev端点assetlinks.json
文件从未用于验证应用程序时,我只是注意到因为深层链接仍然在暂存环境中工作(当它不应该有).
这是Android OS的一个错误(换句话说,它根本不进行资产链接检查?).是的,在安装指向登台的版本之前,我卸载了指向开发服务器的旧应用程序...
以下是官方文档:
https://developer.android.com/training/app-links/
这是段落,特别是我的问题的根源(因为它明确指出,如果任何主机不解析路径上的assetlinks.json
文件/.well-known/
(包括assetlinks.json
针对客户端应用程序验证检索到的文件),那么应用程序将不会迷上接受链接(即status: none
).
When android:autoVerify="true" is present on any one of your intent filters, installing your app on devices with Android 6.0 and higher causes the system to attempt to verify all hosts associated with the URLs in any of your app's intent filters. Verification involves the following:
The system inspects all intent filters that include:
Action: android.intent.action.VIEW
Categories: android.intent.category.BROWSABLE and android.intent.category.DEFAULT
Data scheme: http or https
For each unique host name found in the above intent filters, Android queries the corresponding websites for the Digital Asset Links file at https://hostname/.well-known/assetlinks.json.
Only if the system finds a matching Digital Asset Links file for all hosts in the manifest does it then establish your app as the default handler for the specified URL patterns.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
671 次 |
最近记录: |