16

I have an application which supports universal links and it is currently in the app store.

Say it supports the domain www.example.com and thus universal links can be easily opened via this. We will have applinks:www.example.com in associated domains.

Now say if I want to release another app and it also supports the same domain. Now how will iOS distinguish which app to open via universal links..?

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115

3 Answers3

27

In order to supporting Universal Links with single domain on two different apps you need to make changes in your existing apple-app-site-association file, at https://{domain}/apple-app-site-association.

For Single App Support

For single application support it's look like this

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "1234ABCDE.com.domain.myapp",
                "paths": ["*"]
            }
        ]
    }
}

For Multiple App Support

For multiple application support, you need add one more key-value pair in details array of applinks in apple-app-site-association. It's look like this

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "1234ABCDE.com.domain.myApp",
                "paths": ["*"]
            },
            {
                "appID": "1234ABCDE.com.domain.mySecondApp",
                "paths": ["*"]
            },
            {
                "appID": "1234ABCDE.com.domain.myThirdApp",
                "paths": ["*"]
            }
        ]
    }
}

General Format of apple-app-site-association file

The file looks like this:

{
"applinks": {
    "apps": [ ],
    "details": [
        {
            "appID": "{app_prefix}.{app_identifier}",
            "paths": [ "/path/to/content", "/path/to/other/*", "NOT /path/to/exclude" ]
        },
        {
            "appID": "TeamID.BundleID2",
            "paths": [ "*" ]
        }
    ]
}
}

References

How to support Universal Links in iOS App and setup server for it?

Community
  • 1
  • 1
Vineet Choudhary
  • 7,433
  • 4
  • 45
  • 72
  • 3
    There is a problem with your implementation of your apple-app-site-association file. All your apps are supporting "*", meaning all your apps can handle all the pages of the domain. This way the last app installed will opened every time a universal link is clicked. – Ankit Srivastava Mar 05 '16 at 20:04
  • That's the reason for adding general format for apple-app-site-association – Vineet Choudhary Mar 05 '16 at 20:15
  • what about excluding subdomain instated of path? – Ali A. Jalil Apr 10 '20 at 11:10
4

I found the solution, its pretty simple though. My problem was that my first app was supporting all the pages by stating

"*" in the paths section of apple-app-site-association file. Now all I have to do is add NOT in front of one of the paths which I wanted my second app to handle.

like "NOT /cabs". I haven't tested it yet if this works or not. I will post an update as soon as I am done with it.

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
2

Apple App Site Association file example

{
    "applinks": {
        "apps": [],
        "details": [{
            "appID": "D3KQX62K1A.com.example.photoapp",
            "paths": ["/albums"]
            },
            {
            "appID": "D3KQX62K1A.com.example.videoapp",
            "paths": ["/videos"]
        }]
    }
}

Important: The order of the dictionaries in the array determines the order the system follows when looking for a match. The first match wins, allowing you to designate one app to handle specified paths within your website, and another app to handle the rest.

References: https://developer.apple.com/documentation/uikit/core_app/allowing_apps_and_websites_to_link_to_your_content/enabling_universal_links

foskon
  • 51
  • 4