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

时间:2018-05-15 14:53:31

标签: ios ios-universal-links

我无法让iOS Universal Links接受一种路径,但忽略了另一种非常类似的路径。我想在我的应用中打开的路径如下所示: /details/123567,我想忽略的路径如下所示:/details?search=123456

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

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

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

4 个答案:

答案 0 :(得分:3)

来自Apple's documentation

  

请注意,只有URL的路径组件用于比较。

因此忽略任何查询参数(在?之后)。

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

答案 2 :(得分:1)

我设法解决了这个问题:

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

答案 3 :(得分:0)

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

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

  1. https://www.domainname.com/category1/details/abc
  2. https://www.domainname.com/category2/details?search=12354/abc
  3. 那么你的苹果应用网站应该是

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

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