Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App links intent filters in assetlinks.json not working on Android

My app defines the intent filters to handle URL's from my site defined by

<intent-filter android:autoVerify="true">   <action android:name="android.intent.action.VIEW"/>   <category android:name="android.intent.category.DEFAULT"/>   <category android:name="android.intent.category.BROWSABLE"/>   <data android:host="www.host.com" android:scheme="http"/> </intent-filter> <intent-filter android:autoVerify="true">   <action android:name="android.intent.action.VIEW"/>   <category android:name="android.intent.category.DEFAULT"/>   <category android:name="android.intent.category.BROWSABLE"/>   <data android:host="www.host.com" android:scheme="https"/> </intent-filter> 

The app correctly detects URL's of the correct host but queries the user whether to open them in the app or browser. I tried using the App links verification as specified here: https://developer.android.com/training/app-links/index.html

As seen in my server logs, when installing the app, the device queries /well-known/assetlinks.json and it responds with a 200 status. Testing the digital assets file using the

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

API and it found no errors.

The SHA256 in the assetlinks.json file was obtained using

keytool -list -v -keystore my-release-key.keystore  

the same .keystore of which the app was signed.

Running adb shell dumpsys package d returns that the link verification status is "ask" meaning that verification failed. Why might verification be failing?

like image 542
shadowcursor Avatar asked Feb 20 '16 02:02

shadowcursor


People also ask

What is the role of intent and intent filter in Android?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

What is Assetlinks JSON?

/.well-known/assetlinks.json (spec) A Google specification that allows a site to define its relationship to apps or other sites, e.g. allow links to a site to be opened in an app instead.

How do Android app links work?

Android App Links are HTTP URLs that bring users directly to specific content in your Android app. Android App Links can drive more traffic to your app, help you discover which app content is used most, and make it easier for users to share and find content in an installed app.


1 Answers

For us it was Windows line endings!

Testing with "https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls" proved invaluable as it gave us an "Could not parse statement list (not valid JSON)" error which led us to the problem.

TIP: It was good to use the 'Save File' button in the Android Studio App Links Assistant instead of copying and pasting as we did - that way it generates the file itself and is guaranteed not to have this issue.

like image 92
Marchy Avatar answered Sep 19 '22 14:09

Marchy