我无法让iOS Universal Links接受一种路径,但忽略了另一种非常类似的路径。我想在我的应用中打开的路径如下所示:
/details/123567
,我想忽略的路径如下所示:/details?search=123456
。
首先,我将/details/*
列入白名单,但这打开了两种链接。添加NOT /details?query=*
会阻止所有链接打开。我已经读过路径参数被忽略了。
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /details?search=*", "/details/*"]
}
]
}
}
有没有办法成功区分这两种路径?
答案 0 :(得分:3)
答案 1 :(得分:2)
对于iOS13及更高版本
作为对Supporting Associated Domains的引用,您可以处理网站上的某些URL,或者指定具有特定名称和x字符数或完全匹配值的必需URL查询项。
一个 json 模板:
{
"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"
]
}
}
在WWDC 2019中被提及:What's New in Universal Links
对于一些极端情况和常见问题,有有用的参考文献tutorial。
答案 2 :(得分:1)
我设法解决了这个问题:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /details/", "/details/*"]
}
]
}
}
答案 3 :(得分:0)
实际上有两个因素会影响您的代码实现,第一个是给定路径的顺序。第一条路径优先于其他路径。第二个原因是" / *"表示匹配子字符串。尝试添加" NOT / details?search = / *" (你在明星之前缺少斜线)。如果不是那么
尝试更具体地说明链接,例如,如果两个链接都是
那么你的苹果应用网站应该是
{
"applinks": {
"apps": [],
"details": [
{
"appID": "a.b.c",
"paths": [ "NOT /category1/details/*", "/category2/details/*"]
}
]
}
}
如果仍未解决您的问题,请提及绝对链接?