android - 使用 Android 深层链接时,assetlinks.json 文件的用途是什么?

标签 android deep-linking

我正在尝试获取深层链接以在我的应用中工作。

从我读到的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>

通过 here 阅读“数字 Assets 链接” ,它说:

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> ,如果用户单击指向 http://www.example.com/gizmos 的链接,他们应该看到一个选择器,提供在您的应用程序、可用的 Web 浏览器等中查看该内容。使用 assetlinks.json ,在 Android 6.0+ 上,您可以证明对该域的所有权,这将导致 Android(默认情况下)绕过选择器并直接驱动到您的应用。

关于android - 使用 Android 深层链接时,assetlinks.json 文件的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44209477/

相关文章:

javascript - 使用深层链接在 native react 中打开邮件应用程序

没有相应URL的Android深度链接

java - Recyclerview 适配器中的空指针异常

android - OnKeyListener 不工作

android - onTouchListener 做两次 Action

c# - 我们如何共享我们的 xamarin 应用程序?

android - 谷歌云消息 : duplicate token in database

android - 白名单不适用于人行横道

objective-c - 与 IOS 深度链接混淆

android - 用于在 Firebase for Android 中创建 URL 深层链接的应用程序代码是什么