Article

Enabling Universal Links

Configure your app and website to support universal links.

Overview

By creating a two-way association between your app and your website, you can enable universal links as well as take advantage of other services, such as shared web credentials and Handoff.

Take the following steps to associate your app and website for universal links:

  1. Add the Associated Domains Entitlement to your app. Include all domains your app will support using the applinks service prefix. See Add the Associated Domains Entitlement.

  2. Add an Apple App Site Association file to your website. See Add the Apple App Site Association File.

  3. Add the applinks key to the Apple App Site Association file. Specify the sections of your website each of your apps will handle.

For information about related services, see Shared Web Credentials and Web Browser–to–Native App Handoff.

Add Universal Links Support to Your Association File

To support universal links in the Apple App Site Association file, add an applinks key.

The applinks key contains the following keys:

apps

This key is not used for universal links, but it must be present and set to an empty array, as shown in Listing 1.

details

A list of apps handling universal links for your website, along with the specific sections of your website each app handles.

Listing 1

An Apple App Site Association file supporting universal links

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

Add the value of the details key as a JSON representation of an array of dictionaries, one dictionary per app. For each app-specific dictionary, include an appID and paths key:

appId

The identifier of the application that will handle the links in the format <team identifier>.<bundle identifier>.

paths

The sections of your website supported by the app specified as an array of path strings.

Use Wildcards and Directives in Your Path Strings

Use wildcards in path strings within the paths array to specify sections of your website. For example, append * to a specific URL, such as /videos/samples/2015/*, to specify all paths below /videos/samples/2015/. Use ? to match any single character, such as /photography/*/samples/201?/mypage. Use a standalone * to specify your entire website.

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.

Identify an area that should not be handled by adding “NOT ” (including a space after the T) to the beginning of the path string. For example, the Apple App Site Association file shown in Listing 1 could prevent the /videos/samples/2010/* area of the website from being handled by updating the paths array as shown here:

"paths": [ "/videos/collections/*", "NOT /videos/samples/2010/*", "/videos/samples/201?/*"]

For more information on creating and validating an Apple App Site Association file, see Setting Up an App’s Associated Domains.

See Also

Universal Links

Handling Universal Links

Prepare your app to respond to an incoming universal link.