其他分享
首页 > 其他分享> > 使用Android深层链接时,assetlinks.json文件是什么?

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

作者:互联网

我正在尝试在我的应用中获得深层链接.

从我读的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阅读“数字资产链接”时,它说:

Website A declares that links to its site should open in a designated
app on mobile devices, if the app is installed.

这涉及将assetlinks.json上传到我的服务器.

但是如果意图过滤器已经打开我的应用程序,我无法看到这样做的好处,那么有什么意义呢?

解决方法:

引自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,deep-linking
来源: https://codeday.me/bug/20190527/1164008.html