Discarding deep link if it contains specific path

Viewed 924

I have an implementation of deeplink in my manifest which is working fine

    <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:host="blablabla.com"
              android:scheme="https" />
          <data
              android:host="${applicationId}"
              android:scheme="bla" />
</intent-filter>

I am wondering is there any way to NOT ACCEPT a deep link URL if it contains a specific path? E.g. Do not accept (don't open the app) if blablabla.com/specificPath but do accept any other paths with the same hostname.

1 Answers

Android Deep Links does not provide a way to explicitly exclude URLs, the best practice is define specifically the urls that you want to access to your app using deep Links.

In this case to access URLs like :

www.blablabla.com/specificPath
www.blablabla.com/specificPath/
www.blablabla.com/specificPath/default.aspx
www.blablabla.com/specificPath/other/

You will define the configuration of your intent filter using android:pathPrefix as:

 <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:host="blablabla.com"
              android:scheme="https" 
              android:pathPrefix="/specificPath" />
</intent-filter>
Related