Android Deep Links Not Following Path Prefix
Answer :
I figured it out, It seems like the data tags sort of bleed into one another, so the prefix of "/" on the data with scheme "example" was also applying to all of the schemes in the other data tags. I just had to use separate Intent filters for my custom scheme deep links and the url deep links like so:
<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- must start with http://test.example.com/app --> <!-- http://test.example.com/ won't work since prefix / is in a different intent-filter --> <data android:scheme="http" android:host="test.example.com" android:pathPrefix="/app"/> <!-- must start with http://live.example.com/app --> <data android:scheme="http" android:host="live.example.com" android:pathPrefix="/app"/> </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" /> <!-- must start with example://main/ --> <!-- http://test.example.com/ won't work since http is in a different intent-filter --> <data android:scheme="example" android:host="main" android:pathPrefix="/"/> </intent-filter> </activity>
As explained here, your attributes get merged:
Although it's possible to include multiple
<data>
elements in the same filter, it's important that you create separate filters when your intention is to declare unique URLs (such as a specific combination of scheme and host), because multiple<data>
elements in the same intent filter are actually merged together to account for all variations of their combined attributes.
Putting them into separate instances of <intent-filter>
therefore fixes your problem.
Comments
Post a Comment