4

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.

Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52
  • see this link http://stackoverflow.com/questions/37524073/can-i-broadcast-custom-intent-through-my-html-page-link-from-browser – Divyang Panchal Jun 27 '16 at 08:18
  • The suggested method of using Intent URLs is nice and I am using it successfully, but it only works in places where you can alter the html. I would like to be able to open regular http urls (since they appear in Google search results). – Nino van Hooff Jun 27 '16 at 11:50
  • One thing which can help. You need to fix your `data` section in `intent-filter`. Data tag should include all parameters like this: ``. And the same data should be added for each scheme, host etc. Check example in [Android docs](https://developer.android.com/training/app-indexing/deep-linking.html#adding-filters) – comrade Jul 01 '16 at 12:00
  • 1
    The above is bad advice; it is perfectly reasonable to use one attribute per `data` tag, and indeed most Google app manifests use that style. – j__m Nov 08 '16 at 11:17
  • @j__m, thank you! Your advice helped me. https://stackoverflow.com/a/60342565/2914140. – CoolMind Dec 08 '20 at 20:16

2 Answers2

1

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
Nino van Hooff
  • 3,677
  • 1
  • 36
  • 52
  • I got something like this, https://gist.github.com/chamnap/0613fe642ee5e74e1d28ead2cba2b45c. anything is wrong? – Chamnap Dec 18 '16 at 07:53
  • @Chamnap yes, you should get the contents of your assetlinks.json file back and a footer containing "debugString": "********************* ERRORS *********************\nNone!" – kira_codes Jan 12 '17 at 23:03
1

I had the same problem and the problem was not related to assetlinks.json file. I had 3 different domains and one of them was failing to due some misconfiguration. Even if only one domain was failing, applink was not working for other domains either. You may want to check if all the domains are working as expected.

belphegor
  • 483
  • 7
  • 10
  • Thanks! In my case I had 2 domains in `AndroidManifest`. After removing any of them App Linking worked! In a log I got: `I/IntentFilterIntentOp: Verification 2 complete. Success:true. Failed hosts:.`. Currently searching how to make both domains work. – CoolMind Feb 20 '20 at 14:11
  • 1
    An advice of @j__m helped. I set all `` tags with one attribute. – CoolMind Feb 21 '20 at 09:07