App links and Deep links with Android 12

Idan Damri
5 min readMar 18, 2022

--

Android cool icon image is taken from https://www.freeiconspng.com/img/3085

Deep links — if you are familiar with the concept feel free to jump over to the headline of implementing Deep links with Android 12. For those of you who don’t know what is Deep Link, let’s elaborate a bit on that:

According to Google:

https://developer.android.com/guide/navigation/navigation-deep-link

In Android, a deep link is a link that takes you directly to a specific destination within an app.

As we can understand we can use Deep links as part of our navigation with the app. If the user has the app installed, it will be recognized by the app and navigate according to the implementation, if not - it is really based on how our Deep link is used (HTTP/HTTPS/customed scheme) - navigate to a browser/Play Store.

If you haven’t used or implemented a Deep Link in your app I suggest reading the following guide hand in hand with the link I added above (googles android developer link) and implementing it — there is no better way to learn it other than coding and testing it!

Let’s talk business

I am now in a position as a mobile team leader(I arrived not long ago) for a company that has 2 major apps, both apps' navigation is used a lot with Deep links, Bussines-wise the customer wanted a link that can take a user directly to any flow inside the app with fewer clicks as possible through whatever promotion is used.

The older and more used app is running in both android and apple stores since 2011. Our navigation as I mentioned is mainly Deep links based and in use for a long time. Since Android 12 has been actively spread through main devices (Samsung, Xiaomi, Huawei, and more) we started seeing feedback on navigation issues, partly from the testers and partly from customers.

It took a while to understand that this issue is related to android 12. Once I understood it I started researching what can be the issue. I understood that the main issue in our app is with the deep links in android 12 more specifically App links with Android 12.

A short explanation of the differences:

In our company we use App links (HTTP/HTTPS schemes) because if the app doesn’t exist we would like to direct the user to our company's website, if the app exists (Android or iOS) it will open the app and navigate directly to the beginning of the flow. The problem with android 12 and unverified App links was that if the app was installed on the Android device it navigated to the Play Store rather than opening the app at the correct Activity and flow.

After some more reading and googling my problem was that the app links were not verified, so I followed the following guide by Android:

https://developer.android.com/training/app-links/verify-site-associations

According to them, I needed to create something called an “assetlinks.json” file. There are some ways to create it, I did it in the easiest way there is — just go to your play-console, search for the setup menu on the left, and select “App integrity”, then in the tabs click on “App signing” (If you didn’t go through the app signing process before and enrolled — I super suggest you do it and soon, more about it in the link).

Now scroll down until you see “Digital Asset Links JSON”, for example:

Digital Asset Links JSON

You can copy it all by clicking on the copy to clipboard icon on the top right corner. After copying it to the clipboard, use any online JSON file creator like this and download it and name it “assetlinks.json”.

Once it’s saved on your computer you’ll need to upload it to: https://domain.name/.well-known/assetlinks.json

So google’s mechanism can download it from this link. Here is an example for Wikipedia’s assetlinks.json.

If you did everything right you can use the following Asset links testers tool and test it:

https://developers.google.com/digital-asset-links/tools/generator

For example, if we use Wikipedia’s assetlinks.json we can test it through the Asset links testers tool I showed you and we will see the following process succeded:

There is another way to verify that the file is correct, Google provides a Digital Asset Links API to verify the accuracy of the assetlinks.json file:

https://digitalassetlinks.googleapis.com/v1/statements:list? source.web.site=<https://domain.name:optional_port>&relation=delegate_permission/common.handle_all_urls

As a practical example, here is DoorDash’s link:

https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://www.doordash.com&relation=delegate_permission/common.handle_all_urls

If all goes well, the API will respond with the following:

Michael Yotive Doordash's article

I had one more issue here — when using the verify tool I got an error that my file’s content type wasn’t right and it had to be “Content-Type: application/json”. Learn from my mistake 😜

Thanks a lot for taking the time to read this, I hope the article was helpful. See you guys next time.

--

--

Idan Damri

Enthusiastic Android developer, as GEEK as they get..