I'm using branch.io SDK in my Android app and want to make my app a default handler for branch links on Android 6 as described here(Android guide) and here(Branch.io guide)
This is my activity's declaration in AndroidManifest.xml:
<activity android:name="com.mypackage.MyActivity"
android:launchMode="singleTask">
<intent-filter tools:node="merge" android:autoVerify="true">
<data android:scheme="@string/url_scheme" android:host="open"/>
<data android:scheme="https"
android:host="@string/branch_io_host"
android:pathPrefix="@string/branch_io_path_prefix"/>
<data android:scheme="http"
android:host="@string/branch_io_host"
android:pathPrefix="@string/branch_io_path_prefix"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
However when I install a build on my device, I still keep seeing the chooser dialog when I click on a link with proper host and path. After readin through this extensive guide on app linking, I believe this is happening because my device never verifies my app's intent filter. E.g. when I install a Twitter app from the play store, I see these messages in LogCat:
03-24 15:04:27.231: D/IntentFilterVerificationReceiver(16965): Received ACTION_INTENT_FILTER_NEEDS_VERIFICATION.
03-24 15:04:27.248: I/IntentFilterIntentService(16965): Verifying IntentFilter. verificationId:2 scheme:"https" hosts:"twitter.com www.twitter.com ads.twitter.com" package:"com.twitter.android".
03-24 15:04:30.134: I/IntentFilterIntentService(16965): Verification 2 complete. Success:true. Failed hosts:.
But I don't see messages like this when I install my app. I tried both release and debug builds, tried uploading it to Alpha testing in the play store and installing from there, same result. Why does Android not verify my Intent filter?
Fixed this by moving this data tag into a separate intent filter:
<data android:scheme="@string/url_scheme" android:host="open"/>
This is what AndroidManifest looks like now:
<activity android:name="com.mypackage.MyActivity"
android:launchMode="singleTask">
<intent-filter tools:node="merge" android:autoVerify="true">
<data android:scheme="https"
android:host="@string/branch_io_host"
android:pathPrefix="@string/branch_io_path_prefix"/>
<data android:scheme="http"
android:host="@string/branch_io_host"
android:pathPrefix="@string/branch_io_path_prefix"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<intent-filter>
<data android:scheme="@string/url_scheme" android:host="open"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Messages from IntentFilter now show up in the log as intended.