Support Android App Links for some domains, and Direct Links for other domains!

Bram Yeh
2 min readDec 3, 2020

One Verification Fails, All App Links Fail

(I knew it’s an odd case.) Our android app fully supports Android App Links, and it works perfectly. And then, the app is demanded to handle more domains, however, some domains‘ web servers cannot put the assetlinks.json files onto.

Use ATS policy to redirect assertlinks.json? No, the assetlinks.json file must be accessible without any redirects. And the Android system will verify every host specified in the intent filters’ data elements. If any verification fails, the app is not verified to be a default handler for any of the URL patterns defined in the AndroidManifest.xml.

If we add the URL patterns of new domains into the app’s intent filters, all our App Links fail because the verifications of those new domains fail. If we don’t add the URL patterns of new domains, our users cannot open those contents in our app from mobile browsers.

How about removing all App Link invalid domains from the app’s intent filters? Not acceptable because those domains still need Deep Links. We need to support App Links for some domains, and support Direct Links for the other domains (those web servers can’t add the assetlinks.json files) together in our app.

Request App Links Verification Only for Valid Domains

To enable link handling verification for App Links, we have to set android:autoVerify=”true” in any one of the web URL intent filters that include the android.intent.action.VIEW intent action and android.intent.category.BROWSABLE intent category.

On the contrary, if we move those invalid domain out to other intent filters without android:autoVerify=”true”, the Android system won’t verify those URL patterns.

It’s important to verify app link works or not. To follow Check link policies, use commend adb shell dumpsys package d to see the current link-handling setting:

https://developer.android.com/training/app-links/verify-site-associations#check-link-policies

--

--