1

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

The apple docs have an example apple-app-site-association file that looks like this.

{
    "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?

Thank you

Jon_B
  • 969
  • 4
  • 16
  • 24

2 Answers2

3

As mentioned in this video, we can now use the components array and handle this kind of universal link in iOS 13 and above:

Beginning this year, we are replacing the paths key with the components key.

This key's value is an array of dictionaries, each of which contains zero or more URL components to pattern match against. As before, you can match against the URL's path component whose key is the forward slash. 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. 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.

Now many, if not most URLs out there divide their query component up into key value pairs called query items. 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.

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. 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. 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.

This key has the same behavior as a not keyword that you used in the old paths key. That key word is not supported when using the component's dictionary.

Ishita Sinha
  • 2,168
  • 4
  • 25
  • 38
0

I had this very same question, I was able to find Apple's own information about query strings, see below.

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. 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.

Full page where my quote is taken from can be found here

Conrad
  • 33
  • 1
  • 4