简体   繁体   English

你如何指定一个 apple-app-site-association 文件路径来匹配查询字符串?

[英]How do you specify an apple-app-site-association file path to match query strings?

I'm trying to set up universal linking in a mobile app I am building.我正在尝试在我正在构建的移动应用程序中设置通用链接。 The path I'm trying to match on my website is www.mywebsite.com/route?query=xxx我试图在我的网站上匹配的路径是www.mywebsite.com/route?query=xxx

The apple docs have an example apple-app-site-association file that looks like this.苹果文档有一个像这样的示例apple-app-site-association文件。

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
            },
            {
                "appID": "ABCD1234.com.apple.wwdc",
                "paths": [ "*" ]
            }
        ]
    }
}

But this example does not have an example of a path with a query string.但是此示例没有带有查询字符串的路径示例。

How can I match my route www.mywebsite.com/route?query=xxx in my apple-app-site-association file?如何在我的 apple-app-site-association 文件中匹配我的路线www.mywebsite.com/route?query=xxx

Thank you谢谢

I had this very same question, I was able to find Apple's own information about query strings, see below.我有同样的问题,我能够找到 Apple 自己关于查询字符串的信息,见下文。

Note笔记

The strings you use to specify website paths in the paths array are case-sensitive.用于在路径数组中指定网站路径的字符串区分大小写。 Only the path component of the URL is used for comparison.仅使用 URL 的路径部分进行比较。 Other components, such as the query string or fragment identifier, are ignored.其他组件,例如查询字符串或片段标识符,将被忽略。

So in-short they would ignore anything from your link after "route", you would just use /route as the path.所以简而言之,他们会在“路由”之后忽略您链接中的任何内容,您只需使用 /route 作为路径。

Full page where my quote is taken from can be found here可以在此处找到我引用的完整页面

As mentioned in this video , we can now use the components array and handle this kind of universal link in iOS 13 and above:正如本视频中提到的,我们现在可以在 iOS 13 及更高版本中使用components数组并处理这种通用链接:

Beginning this year, we are replacing the paths key with the components key.从今年开始,我们将把paths键替换为components键。

This key's value is an array of dictionaries, each of which contains zero or more URL components to pattern match against.此键的值是一个字典数组,每个字典包含零个或多个 URL 组件以进行模式匹配。 As before, you can match against the URL's path component whose key is the forward slash.和以前一样,您可以匹配 URL 的path组件,其键是正斜杠。 If you need to support previous releases, you can keep the paths key.如果您需要支持以前的版本,您可以保留路径键。

iOS 13, tvOS 13 and macOS 10.15 will ignore it if the components key is present.如果存在 components 键,iOS 13、tvOS 13 和 macOS 10.15 将忽略它。 And now you can match against the URL's fragment component whose key is the hash mark and you can match the query component whose key is the question mark.现在,您可以匹配键为哈希标记的 URL 片段组件,也可以匹配键为问号的查询组件。

Now many, if not most URLs out there divide their query component up into key value pairs called query items.现在很多(如果不是大多数)URL 将它们的查询组件分成称为查询项的键值对。 For the query component, you can specify a dictionary instead of a string as its value and pattern match individual query items.对于查询组件,您可以指定字典而不是字符串作为其值和模式匹配各个查询项。 URLs may repeat query item names and the operating system will require that all instances of a given query item name match your pattern. URL 可能会重复查询项名称,操作系统将要求给定查询项名称的所有实例都与您的模式匹配。

Example:例子:

"components": [
      {
              "/": "/help/*",
              "?": { "articleNumber": "????", "articleName": "?*" },
              "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, and another with name 'articleName' and a value of one or more characters"
           }
    ]

Query items with no value and absent query items are treated by the operating system as if they have a value equal to the empty string.操作系统将没有值和不存在查询项的查询项视为具有等于空字符串的值。

For a components dictionary to match a candidate URL, all the specified components must match.对于要匹配候选 URL 的组件字典,所有指定的组件都必须匹配。 If you don't specify a component, the operating system's default behavior is to simply ignore that component.如果您不指定组件,操作系统的默认行为是简单地忽略该组件。 So if, for example, your app doesn't care about the fragment component of a URL, you don't need to specify it in this file.因此,例如,如果您的应用不关心 URL 的片段组件,则无需在此文件中指定它。 You may have sections of your website that are not able to be represented in your app yet.您网站的某些部分可能还无法在您的应用中呈现。 You can exclude such subsections by specifying the exclude key with a Boolean value of true.您可以通过使用布尔值 true 指定排除键来排除此类子部分。

This key has the same behavior as a not keyword that you used in the old paths key.此键与您在旧路径键中使用的 not 关键字具有相同的行为。 That key word is not supported when using the component's dictionary.使用组件的字典时不支持该关键字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用与组件参数完全匹配的 apple-app-site-association 文件? - How do I use the apple-app-site-association file with a component parameter exact match? 如何在 ReactJS 中的 /apple-app-site-association 页面上提供 apple-app-site-association 文件 - How to serve apple-app-site-association file on /apple-app-site-association page in ReactJS apple-app-site-association文件的位置 - Location for apple-app-site-association file 我向apple-app-site-association文件添加了新路径,但仍然无法正常工作 - I added a new path to apple-app-site-association file but still doesn't work Apple-app-site-association:横幅显示,而服务器中没有文件 - Apple-app-site-association : banner displays while no file in server 苹果应用站点关联文件无法为某些用户下载 - Apple-app-site-association file fails to download for certain users iOS 通用链接 apple-app-site-association 文件问题 - iOS Universal links apple-app-site-association file issue DeepLinking apple-app-site-association文件是否需要签名? - Does DeepLinking apple-app-site-association file need signing? apple-app-site-association文件格式错误 - The apple-app-site-association file format error 配置 apple-app-site-association 文件并上传到服务器 - Configure apple-app-site-association file and upload on server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM