Universal links on iOS

Universal Links are standard web links (http://your_domain.com) that point to both a web page and a piece of content inside an app.

When users tap or clicks on an universal link, the system redirects the link directly to your app without routing through Safari or your website. In addition, because universal links are standard HTTP or HTTPS links, one URL works for both your website and your app. If the user has not installed your app, the system opens the URL in Safari, allowing your website to handle it.

When users install your app, the system checks a file stored on your web server to verify that your website allows your app to open URLs on its behalf. Only you can store this file on your server, securing the association of your website and your app.

This guide will show you how to enable universal app links support for your cidaas-registered application.

Configure universal links

Steps to configure universal links to your app are as follows,

  • Configure your app in apple developer portal to register approved domains
  • Enable Associated Domains in your Xcode project
  • Prepare your app to handle Universal Links in Xcode
  • Configure your website to host the apple-app-site-association file

Configure your app in apple developer portal

In order to register your Xcode project for Universal Links, you need to create an App ID in the Apple developer portal and enable the proper entitlements.

1. Login to developer.apple.com and register your app.

2. Then click on Certificates, Identifiers & Profiles, and then click on Identifiers.

3. Select your App ID and click on Edit. Then enable 'Associated Domains' on your app identifier. Then click on Save.

Enable Associated Domains in your Xcode project

Now, you’ll want to enable the Associated Domains entitlement within your Xcode project.

First, make sure that your Xcode project has the same Team selected as where you just registered your App Identifier.

1. Now, go to the Capabilities tab of your project file. In the domains section, add the appropriate domain tag. You must prefix it with applinks:. In this case, you can see we added applinks:example.com.

2. If you see any error here, check:

  • That you have the right team selected.
  • Your bundle identifier of your Xcode project matches the one used to register the App identifier in developer portal.

To handle the link inside your app when it is opened by Universal Link just implement application:continueUserActivity:restorationHandler: on your AppDelegate.

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        let url = userActivity.webpageURL!
        Cidaas.shared.handleToken(url: url)
       return true
    }

Configure your website to host the AASA file

When the app is installed or updated, iOS will check which websites are acceptable by this app as Universal Links. It will then check each of these websites to verify the app is registered there. This is done by placing a file with the app IDs on the website and a list of domains on the app.

NOTE:

If the domain mentioned in the redirect url for your ios app in cidaas admin-ui is cidaas domain then app linking will work automatically. So, no need to follow the upcoming steps.

In case, if the redirect url in cidaas admin-ui is your own domain, then you must need to configure your domain to integrate app-links.


Steps to host AASA file

1. Create your AASA JSON

The AASA (short for apple-app-site-association) is a file that lives on your website and associates your website domain with your native app.

The AASA file contains a JSON object with a list of apps and the URL paths on the domain that should be included or excluded as Universal Links.

Here is a sample AASA file:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "TeamId.AppBundleId_1",
                "paths": ["/pageURL/1", "pageURL/2", "pageURL/3"]
            },
            {
                "appID": "TeamId.AppBundle_2",
                "paths": ["/pageURL/new"]
            },
            {
                "appID": "TeamId.AppBundle_3",
                "paths": [ "*" ]
            }
        ]
    }
}
  • apps : The "apps" key in the apple-app-site-association file must be present and its value must be an empty array.

  • details : The value of the "details" key is an array of dictionaries, one dictionary per app that your website supports.

  • appID : Built by combining your app’s Team ID (goto https://developer.apple.com/account/#/membership/ to get the teamID) and the Bundle Identifier.

  • paths : Array of strings that specify which paths are included or excluded from association. You can use NOT (before the path — as in the example JSON above) to disable paths. In this case, all the links on this path will go to the web instead of opening the app. You can use as a wildcard to enable all paths in a directory (apple doc says: Use to specify your entire website) and ? to match a single character (/archives/201?/ example in the sample JSON). Please note that these strings are case sensitive and that query strings and fragment identifiers are ignored.

2. Hosting the AASA file on your domain

Once you are ready with your AASA file, you can now host it on your domain either at https://<< yourdomain >>/apple-app-site-association or at https://<< yourdomain >>/.well-known/apple-app-site-association.

Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.

Note : 

While hosting the AASA file, please ensure that the AASA file:

* Is served over HTTPS.
* Uses application/json MIME type.
* Don’t append .json to the apple-app-site-association filename.
* Has a size not exceeding 128 Kb (requirement in iOS 9.3.1 onwards).

Testing

Now that your app and website are setup all you have left is to test it. Load an HTTPS link which is configured as described above. If your app is installed it should open the app, otherwise it should open the website.




results matching ""

    No results matching ""