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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With