Tips for Implementing Universal Links into Your iOS Apps
Hello everyone 👋, in this article, we’ll look at how to implement universal links in iOS applications.
Introduction
A universal link is essentially an HTTPS link, which has been configured under the root directory of its domain file. You can specify an HTML5 page for such a link. When a user taps the universal link, they will be redirected to the app’s content if the app has been installed and registered for that domain. If the app has not been installed, the HTML5 page will be displayed in Safari. Universal links are a good way of providing seamless redirection for users. There are other use cases where app linking can be used. Here, there are some to give you idea of use cases:
- Waking up inactive users or increasing views of a specific page,
- Converting mobile website users into native app users,
- Tracking traffic sources in daily marketing to identify the most effective marketing platform,
- Encouraging users to share links,
- Providing a unified download link
Advantages of Universal Links
Unique: Unlike custom URL schemes, universal links link to your website using standard HTTPS so that they cannot be claimed by other apps. Moreover, custom URL schemes have no built-in fallback option, meaning that if a user has not installed an app, they will see an error page in Safari as these links cannot be opened normally. As universal links are essentially web links, they can bypass these problems.
Secure: If a user has installed your app, iOS checks the associated domain file you have uploaded to your web server, which specifies the apps that can be launched by universal links. Only you can create and upload this file, so the connection between your website and your app is secure.
Flexible: Even when your app is not installed, universal links can still open your website’s content when being tapped.
Simple: One HTTPS link works for both your website and app.
Private: Other apps can communicate with your app without needing to know whether it is installed.
Configuring a Universal Link
1. Before you begin, you need to first register a domain that supports HTTPS, and obtain the permission for uploading the associated domain file specified by iOS to the root directory.
2. On the Apple Developer portal, go to Identifiers > App IDs, enable Associated Domains, and click Save. Download the provisioning files and configure them in Xcode.
3. In Xcode, select your project, and go to Targets > Signing & Capabilities > Associated Domains, where Domains indicates your website domains that should be prefixed with applinks:
4. Create a JSON file that will be requested by iOS to verify the associated domains. Do not append .json to the apple-app-site-association file name. The file format is as follows:
Note:
appID: The value of the parameter is in the format of teamId.yourapp’s bundle identifier (the team ID followed by the bundle ID). In the sample code, the team ID is set to ABCD1234. You can find the team ID under Account > Membership on the Apple Developer portal.
paths: The value of the parameter specifies your website paths that are supported by your app. Only links to these paths can be handled by your app. * indicates all links with associated domains of your website.
Upload the associated domain file to the root directory of the domain file or the .well0-known subdirectory. After that, check whether the file is in the target directory.
Testing the Universal Link
In this part, I will also show you to test the universal link created by the App Linking service of AppGallery Connect.
- Create a universal link, and configure the team ID from Apple Developer, in AppGallery Connect.
2. Access the associated domain file (https://your_applinking_url_prefix/apple-app-site-association), generated in AppGallery Connect.
3. In this example, accessing the above domain will redirect you to AppGallery Connect. If you use your own domain, accessing it will launch your app.
Tips & Tricks:
- Universal links work only when the domain of the current web page differs from that of the redirection URL.
Summary
In this article, we have learnt when user taps the universal link, how to be redirected to the app’s content if the app has been installed. Unless the app has been installed, then how HTML5 page to be displayed in Safari web browser.
Reference:
You can contact with me for your questions. See you next!
https://www.linkedin.com/in/do%C4%9Fan-burak-ziyanak-2549542b/