Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the assetlinks.json file for, when using Android deep links?

I'm trying to get deep links to work in my app.

From what I read here, it is enough to add an Intent filter to the app. I tried that and it works fine:

  <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>

Reading about "digital asset links" over here, it says:

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

This involves uploading an assetlinks.json to my server.

But I cannot see the benefit of doing this if the intent filter already opens my app, so what is the point?

like image 328
Krumelur Avatar asked May 26 '17 20:05

Krumelur


People also ask

What does Assetlinks JSON do?

With assetlinks. json , on Android 6.0+, you can prove ownership over that domain, and that will cause Android to (by default) bypass the chooser and drive straight to your app.

What is Assetlinks?

Overview. The Digital Asset Links protocol and API enable an app or website to make public, verifiable statements about other apps or websites. For example, a website can declare that it is associated with a specific Android app, or it can declare that it wants to share user credentials with another website.

How do deep links work Android?

A deep link is a URL that navigates to a specific destination in your app. When you click a deep link, Android: Opens the user's preferred app that can handle the link, if it's available. If the preferred app isn't available, it opens the only app that can handle the link.


1 Answers

Quoting from 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.

Right now, with your <intent-filter>, if the user clicks on a link to http://www.example.com/gizmos, they should see a chooser, offering to view that content in your app, available Web browsers, etc. With assetlinks.json, on Android 6.0+, you can prove ownership over that domain, and that will cause Android to (by default) bypass the chooser and drive straight to your app.

like image 164
CommonsWare Avatar answered Nov 15 '22 20:11

CommonsWare