使用 Android 深层链接时,assetlinks.json 文件有什么用?
What is the assetlinks.json file for, when using Android deep links?
我正在尝试获取深层链接以在我的应用程序中工作。
根据我的阅读here,向应用程序添加 Intent 过滤器就足够了。我试过了,效果很好:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
</intent-filter>
阅读 "digital asset links" 超过 here,它说:
Website A declares that links to its site should open in a designated
app on mobile devices, if the app is installed.
这涉及将 assetlinks.json
上传到我的服务器。
但是如果 Intent 过滤器已经打开了我的应用程序,我看不到这样做的好处,那有什么意义呢?
引用自a different piece of documentation:
Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link. If the user doesn't want the app to be the default handler, they can override this behavior from Settings.
Automatic handling of links requires the cooperation of app developers and website owners. A developer must configure their app to declare associations with one or more websites, and to request that the system verify those associations. A website owner must, in turn, provide that verification by publishing a Digital Asset Links file. A Digital Asset Links file is a collection of statements conforming to the Asset Links protocol that make public, verifiable assertions about other apps or websites.
现在,使用您的 <intent-filter>
,如果用户点击 link 到 http://www.example.com/gizmos
,他们应该会看到一个选择器,提供在您的应用中查看该内容的选项,可用Web 浏览器等。使用 assetlinks.json
,在 Android 6.0+ 上,您可以证明对该域的所有权,这将导致 Android(默认情况下)绕过选择器并直接进入你的应用程序。
我正在尝试获取深层链接以在我的应用程序中工作。
根据我的阅读here,向应用程序添加 Intent 过滤器就足够了。我试过了,效果很好:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
</intent-filter>
阅读 "digital asset links" 超过 here,它说:
Website A declares that links to its site should open in a designated app on mobile devices, if the app is installed.
这涉及将 assetlinks.json
上传到我的服务器。
但是如果 Intent 过滤器已经打开了我的应用程序,我看不到这样做的好处,那有什么意义呢?
引用自a different piece of documentation:
Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler of a given type of link. If the user doesn't want the app to be the default handler, they can override this behavior from Settings.
Automatic handling of links requires the cooperation of app developers and website owners. A developer must configure their app to declare associations with one or more websites, and to request that the system verify those associations. A website owner must, in turn, provide that verification by publishing a Digital Asset Links file. A Digital Asset Links file is a collection of statements conforming to the Asset Links protocol that make public, verifiable assertions about other apps or websites.
现在,使用您的 <intent-filter>
,如果用户点击 link 到 http://www.example.com/gizmos
,他们应该会看到一个选择器,提供在您的应用中查看该内容的选项,可用Web 浏览器等。使用 assetlinks.json
,在 Android 6.0+ 上,您可以证明对该域的所有权,这将导致 Android(默认情况下)绕过选择器并直接进入你的应用程序。