13

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?

1 Answer 1

27

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.

4
  • assetlinks will help you in case of supporting applinks and instanapps
    – bostan
    Jan 18, 2018 at 12:02
  • do you know what would be the expected behaviour if our web app doesn't have native apps? I saw these requests being made by the bot. should we just ignore or put an empty json? I couldnt find information about this case Jul 4, 2022 at 7:55
  • @user2472368: "I saw these requests being made by the bot" -- if you mean requests for assetlinks.json, I would expect you to return a 404 if you do not have a resource for that path. That is fairly standard Web behavior. Jul 4, 2022 at 11:03
  • @bostan what do you mean by supporting applinks and instantapps, could you drop a link that describes more on that? I am trying to generate a url that can launch both instantapps and applinks but not sure whether deep links help with that.
    – sean
    May 9, 2023 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.