iOS 通用链接 : how to exclude certain paths from URL?

标签 ios ios9 ios-universal-links

我正在使用 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/

相关文章:

ios - 在UITableView中使用自动布局以获取动态单元格布局和可变的行高

iphone - 您可以对 Facebook 帖子进行地理标记吗?

swift - 演示 iAds 在模拟器上的 iOS 9/9.1 Xcode 7.1.1 上不工作,在设备上也不工作

hook - Instagram 共享不适用于 iOS 9

ios - UITextView : Tapping a universal deep link that should lead to the SAME app, 在 Safari 中打开回退 URL

ios - UIWebView 不显示 HTML

ios - Swift 中的响应链(UIButton 目标中的 nil 目标)

swift - FBSDKApplicationDelegate 申请openURL :sourceApplication:annotation deprecated

ios - 从另一个应用程序打开一个应用程序到特定的 VC

ios-universal-links - App Search API 验证工具显示 "example.com is returning 469. Please check your url and try again."