Reputation: 429
I can't get iOS Universal Links to accept one kind of path but ignore another quite similar one. Paths that I want to open in my app look like this:
/details/123567
, paths that I want to ignore look like this: /details?search=123456
.
At first, I whitelisted /details/*
but that opened both kind of links. Adding NOT /details?query=*
prevented all links from opening. I've read that path parameters are ignored.
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /details?search=*", "/details/*"]
}
]
}
}
Is there a way to successfully distinguish between both kinds of paths?
Upvotes: 2
Views: 3992
Reputation: 1872
For iOS13 and later
As reference to Supporting Associated Domains you can handle certain URLs on your website, or specify a required URL query item with a particular name and a value of x numbers of characters, or exact match.
A json template:
{
"applinks": {
"details": [
{
"appIDs": [
"ABCDE12345.com.example.app",
"ABCDE12345.com.example.app2"
],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
},
{
"/": "/buy/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
},
{
"/": "/help/*",
"?": {
"articleNumber": "????"
},
"comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"
}
]
}
]
},
"webcredentials": {
"apps": [
"ABCDE12345.com.example.app"
]
}
}
It was mentioned in WWDC 2019: What's New in Universal Links
There is a helpful reference tutorial for some edge cases and common issues.
Upvotes: 5
Reputation: 429
I've managed to fix it:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /details/", "/details/*"]
}
]
}
}
Upvotes: 4
Reputation: 36
Actually there are two factors affecting your code implementation, number one is the order of given paths. The first path has highest priority over other path. The second reason is the " /* " means matching sub-string. try adding "NOT /details?search=/*" (you are missing slash before star). If not then
try to be more specific about links for example if both links are
then your apple app site assciation should be
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /category1/details/*", "/category2/details/*"]
}
]
}
}
if still not solving your issue then mention absolute links ?
Upvotes: 0
Reputation: 17874
From Apple's documentation:
Note that only the path component of the URL is used for comparison.
So any query parameters (after the ?
) are ignored.
Upvotes: 6