Android deeplink for every fragrance

I have several deeplink schemes for different applications. I have a backend that sends a different circuit for each application. If all of them are installed on one device, all of them will be able to parse the sent deindvik. Therefore, when all three are installed and deeplink is called for app2. All applications can catch it, but only application2 can correctly process it in the application and should be the only one who can catch it.

Flavors defined in my .gradle file

productFlavors { app1{ applicationId "com.apps.app1" } app2{ applicationId "com.apps.app2" } app3{ applicationId "com.apps.app3" } } 

An intent filter that I use to catch deeplinks in my manifest.

 <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:pathPrefix="/" android:scheme="app1" /> <data android:pathPrefix="/" android:scheme="app2" /> <data android:pathPrefix="/" android:scheme="app3" /> </intent-filter> 

Is there a way to make deeplink only catch one flavor?

+5
source share
2 answers

You must provide each flavor of the product with its own manifest file, within which you can specify a URI template different for deep links.

You can refer to Configure build options and Combine multiple manifest files for more information on how to achieve this, and much more about creating an application for the product.

+3
source

For people visiting this in 2019: You can use manifestPlaceholders for each fragrance. In your case:

 productFlavors { app1{ applicationId "com.apps.app1" manifestPlaceholders.scheme = "app1" } app2{ applicationId "com.apps.app2" manifestPlaceholders.scheme = "app2" } app3{ applicationId "com.apps.app3" manifestPlaceholders.scheme = "app3" } } 

and then use it in your manifest:

 <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:pathPrefix="/" android:scheme="${scheme}" /> 

+4
source

Source: https://habr.com/ru/post/1265816/


All Articles