I've just finished working through adding deeplinks to my React Native app.
I have a question around limiting the paths that work with deeplinks.
I'm using the new components array in the apple-app-site-association
file with wildcards to deeplink specific paths.
My app has routes for map
, places
, routes
and profiles
that can be linked to with params like so:
- https://example.com/map
- https://example.com/places/place-name
- https://example.com/routes/1
- https://example.com/profile/2
These all work as expected, however when a link looks like the following:
https://example.com/places/place-name/another-path-section
, it opens the app on the home screen.
I'd like links with extra path sections to link to the website so they can hit my 404 screen.
Is there a way to do this with the apple-app-site-association
file and android <intent-filter>
?
My apple-app-site-association
file:
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": [
"[teamId].my.app"
],
"components": [
{
"/": "/map/*",
"comment": "Matches any URL with a path that starts with /map/."
},
{
"/": "/places/*",
"comment": "Matches any URL with a path that starts with /places/."
},
{
"/": "/routes/*",
"comment": "Matches any URL with a path that starts with /routes/."
},
{
"/": "/profile/*",
"comment": "Matches any URL with a path that starts with /profile/."
},
]
}
]
}
}
I have tried adding exclude blocks like this:
{
"/": "/places/*/*",
"exclude": true,
"comment": "Excludes any URL with a path that starts with /places/[param]/[more-paramas]."
},
But it still behaves the same.
Similarly, my intent-filter looks like this:
<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:host="example.com"
android:scheme="https"
android:path="/map" />
<data android:pathPrefix="/routes" />
<data android:pathPrefix="/places" />
<data android:pathPrefix="/profile" />
<data
android:host="example.com"
android:scheme="http" />
</intent-filter>
And I have tried the same kind of path as in my apple components:
<data android:pathPattern="/places/*" />