通用Link 只开放基地URL

Universal Link open only base URL

是否可以在 apple-app-site-association 文件中的 "paths" 数组中设置一个路径,该路径将只打开应用程序中的原始域?

例如, 如果我的域名是 https://www.example.com

我希望在用户单击 link 时打开该应用程序 https://www.example.com

但不会 https://www.example.com/a

我没有测试下面的解决方案,所以我不能保证它们会起作用。同时他们都是基于documentation,所以他们应该。我目前不想花时间为此设置测试环境,所以如果您分享您的测试结果就太好了。

我的第一个建议是:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "%YOUR.APP.ID%",
        "paths": [
             "/"
        ]
      }
    ]
  }
}

如果这没有帮助,这是另一个:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "%YOUR.APP.ID%",
        "paths": [
             "NOT /?*",
             "/*"
        ]
      }
    ]
  }
}

这里?匹配任意单个字符,*匹配任意子串,包括空。第二种情况的想法是系统可能会使用从上到下的规则。

Because the system evaluates each path in the paths array in the order it is specified—and stops evaluating when a positive or negative match is found—you should specify high priority paths before low priority paths. https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html?utm_source=revxblog

第三个想法是首先排除所有你知道的顶级组件然后添加允许所有。这可能真的让人不知所措,尤其是如果您不控制路径或路径发生变化时。