androiduriurl-schemeapplinksdigital-assets-links

Android: app linking - supporting only certain paths?


I want to setup app linking for my app but only for it to be active on certain paths. In other words, in my manifest:

<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" android:host="www.mydomain.com/[mypath]" />
<data android:scheme="https" android:host="www.mydomain.com/[mypath]" />
</intent-filter>

I don't want every url that has my domain to open the app - they can open in the browser as usual. I only want urls that include the specific subpath to open in the app. Is this pattern allowed or is it "all or nothing" for app linking?

Link to the developer docs: http://developer.android.com/training/app-links/index.html


Solution

  • You can have special paths, but you can't/shouldn't have them appended to the host.

    You should have

    <data android:scheme="https" android:host="www.mydomain.com" />
    

    And from there you can use the android:path android:pathPattern or android:pathPrefix to create special patterns.

    For example,

    <data android:scheme="https" android:host="www.google.com" android:path="/en/index.html"/>
    

    would only catch the url "https://www.google.com/en/index.html"