我正在使用 iOS 的新通用链接功能,但想为该功能禁用我主页的某些路径。
例如:所有包含“_id_”和起始页但不包含 http://example.com/testsite 的 URLS来自域http://example.com应该在我的应用程序中打开。我该如何解决这个问题?
我在服务器上的 apple-app-site-association 文件如下所示:
{
"activitycontinuation": {
"apps": [
"ABCDEFGHIJ.com.example.ios"
]
},
"applinks": {
"apps": [],
"details": [
{
"appID": "ABCDEFGHIJ.com.example.ios",
"paths": [
"/",
"*_id_*"
]
}
]
}
}
我在应用程序中的权利文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>activitycontinuation:example.com</string>
<string>activitycontinuation:www.example.com</string>
<string>activitycontinuation:m.example.com</string>
<string>applinks:example.com</string>
<string>applinks:www.example.com</string>
<string>applinks:m.example.com</string>
</array>
</dict>
</plist>
我没有找到任何排除某些路径的选项。这怎么可行?
最佳答案
在路径前加上NOT 以排除该路径被匹配。示例 -
{
"applinks": {
"apps": [ ],
"details": [
{
"appID": "{app_prefix}.{app_identifier}",
"paths": [ "NOT /path/to/exclude"]
}
]
}
}
定义路径有3种方式:
静态
:整个支持的路径被硬编码以识别特定链接,例如/静态/术语
通配符
:* 可用于匹配动态路径,例如/books/* 可以匹配任何作者页面的路径。 ?在特定路径组件内,例如书籍/1?可用于匹配任何 ID 以 1 开头的书籍。
Exclusions
:在路径前加上 NOT 会排除该路径被匹配。
数组中提到路径的顺序很重要。较早的索引具有较高的优先级。一旦路径匹配,评估就会停止,其他路径将被忽略。每个路径都区分大小写。
引用
How to support Universal Links in iOS App and setup server for it?
关于iOS 通用链接 : how to exclude certain paths from URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32884137/