Nino van Hooff Nino van Hooff - 26 days ago 23
Android Question

Android: intent filter verification failure

My goals is to have Android automatically open any link that starts with

test.touchwonders.com
in my app. I have place the required file on my server:
https://test.touchwonders.com/.well-known/assetlinks.json


This is the relevant part of my manifest:

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.justbrands.highstreet.pmelegend.PmeApplication">
<activity
android:name="com.highstreet.core.activity.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" />
<data android:scheme="https" />
<data android:host="test.touchwonders.com" />
<data android:host="www.test.touchwonders.com" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="pme-legend"/>
</intent-filter>

</activity>
</application>


When installing the app, however, this is the output I see in logcat:

06-27 09:48:43.267 6488-6488/? D/IntentFilterVerRcvr: Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
06-27 09:48:43.276 6488-8080/? I/IntentFilterIntentSvc: Verifying IntentFilter. verificationId:14 scheme:"https" hosts:"test.touchwonders.com www.test.touchwonders.com" package:"com.justbrands.highstreet.pmelegend.acceptance".
06-27 09:48:43.531 6488-8080/? I/IntentFilterIntentSvc: Verification 14 complete. Success:false. Failed hosts:test.touchwonders.com,www.test.touchwonders.com.


My device uses the Charles proxy which allows you to see requests. I see no requests going out to test.touchwonders.com tough. I used
adb shell pm clear com.android.statementservice
beffore installing, which should have cleared the cache and forced a re-fetch of the json.

Answer

It turned out the problem was not in my app, but in the assetlinks.json file on the website's server. In my case the problem was that the MIME type oft he server's response was not application/json My real problem was that I did not have a method of testing my assetlinks file. I have found one in the meantime:

Refer to https://developer.android.com/training/app-links/index.html#testing

and use the testing url

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