iOS 通用链接:忽略带有参数的路径

iOS Universal Links: Ignore path with parameters

我无法让 iOS 通用链接接受一种路径而忽略另一种非常相似的路径。我想在我的应用程序中打开的路径如下所示: /details/123567,我想忽略的路径如下所示:/details?search=123456.

起初,我将 /details/* 列入了白名单,但这两种链接都打开了。添加 NOT /details?query=* 会阻止所有链接打开。我读到路径参数被忽略了。

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "a.b.c",
        "paths": [ "NOT /details?search=*", "/details/*"]
      }
    ]
  }
}

有没有办法成功区分这两种路径?

来自Apple's documentation

Note that only the path component of the URL is used for comparison.

所以任何查询参数(在 ? 之后)都将被忽略。

实际上有两个因素会影响您的代码实现,第一是给定路径的顺序。第一条路径比其他路径具有最高优先级。第二个原因是“/*”表示匹配子串。尝试添加 "NOT /details?search=/*" (您在星号之前缺少斜杠)。如果不是那么

尝试更具体地说明链接,例如,如果两个链接都是

  1. https://www.domainname.com/category1/details/abc
  2. https://www.domainname.com/category2/details?search=12354/abc

那么您的苹果应用程序站点关联应该是

  {
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "a.b.c",
        "paths": [ "NOT /category1/details/*", "/category2/details/*"]
      }
    ]
  }
}

如果仍然不能解决您的问题,请提及绝对链接?

我已成功修复:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "a.b.c",
        "paths": [ "NOT /details/", "/details/*"]
      }
    ]
  }
}

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"
    ]
  }
}