Apple launched Universal Links on iOS9 in 2015 as an alternative solution to deep linking and URI schemes.

Let’s begin with a definition of universal linking 

Universal linking is Apple’s solution of pointing a link to a website page or application regardless of whether the application is installed on the user’s phone. It is a deep linking protocol exclusive to Apple devices version 9 and later. 

What is unique about Universal Linking?

Universal links allow users to intelligently follow links to content in your app or your website. They provide users with an integrated mobile and desktop experience, even when your app isn’t installed on their phone.

Some of the benefits of universal links, according to Apple, are

  • Security,
  • Flexibility,
  • Simplicity,
  • Uniqueness,
  • Privacy.

What are Universal links used for?

Developers use universal links to create a two-way association between their mobile applications and website. A universal link can open both, depending on the user’s preference.

How does iOS Universal Link Work?

A universal link is a single link that can take the user to a specific place in an app or an associated webpage. The link’s path depends on whether the app is installed on the user’s phone and the preferences based on previous interactions with universal links.

A universal link aims to respect where the user wants to view the content if a web browser or an application. When users click on a universal link, the system redirects the link directly to the application without going through Safari.

Universal links are standard HTTP or HTTPS links. Therefore, a single link can connect to an app and a website. If a user installs your app, the system verifies your website and allows your app to open URLs on its behalf.

In addition, apps can communicate with each other through universal links. 

An app that supports universal links allows other apps to send small amounts of data, directly to the app, without using a third-party server.

The Apple documentation brings the following example of using universal linking to communicate between apps: 

A photo library app that specifies parameters, including the name of an album and the index of a photo to display.

https://myphotoapp.example.com/albums?albumname=vacation&index=1

https://myphotoapp.example.com/albums?albumname=wedding&index=17

Other apps can create an URL based on the domain, path, or parameter. Then they can ask the app to open them by using one of these methods for calling:

1,  open(_:options:completionHandler:) method of UIApplication in iOS and tvOS

Here is a code example of an app calling the universal link in iOS and tvOS

if let appURL = URL(string: "https://myphotoapp.example.com/albums?albumname=vacation&index=1") {

 UIApplication.shared.open(appURL) { success in

  if success {

 print("The URL was delivered successfully.")

    } else {

     print("The URL failed to open.")

   }

   }

} else {

print("Invalid URL specified.")

}

2. openSystemURL(_:) method of WKExtension in watchOS

Here is a code example of an app calls your universal link in watchOS:

if let appURL = URL(string: "https://myphotoapp.example.com/albums?albumname=vacation&index=1") {

  WKExtension.shared().openSystemURL(appURL)

} else {

    print("Invalid URL specified.")

}

3. open(_:withApplicationAt:configuration:completionHandler:) method of NSWorkspace in macOS

Here is a code example of an app calling an universal link in macOS:

if let appURL = URL(string: "https://myphotoapp.example.com/albums?albumname=vacation&index=1") {

   let configuration = NSWorkspace.OpenConfiguration()

  NSWorkspace.shared.open(appURL, configuration: configuration) { (app, error) in

 guard error == nil else {

 print("The URL failed to open.")

return

     }

  print("The URL was delivered successfully.")

 }

} else {

  print("Invalid URL specified.")

}

How do you support universal links? 

According to Apple developer documentation, an app developer that wants iOS users to connect to the app with universal links must take the following steps:

  1. Creating a two-way association between the app and the website, specifying the URLs of the application.
  2. Updating the app delegate to respond to user activity when a universal link routes the app.

Benefits of Universal Links

There are several advantages to using universal links:

Simplified User Experience 

Before universal links, users that wanted to connect to an app from a link, were served a pop-up prompt asking where they wanted to open the app. This disrupted the user experience and often resulted in users bouncing away.

Universal links take the user where they want to go with a single link. Thus simplifying the user experience. Because there are no disruptions, the chances of conversions are greater.

Engagement 

Universal links are also a way to increase user engagement. Marketers can direct the link to the best location in the app for conversions. Users then can go exactly where they need, resulting in more efficient use of the app.

User Retention 

Happy users come back. Not only there is an improved user experience, but users can convert faster, — complete purchases in fewer steps—. Therefore, universal links tend to increase retention and conversion rates.

Enhanced Analytics 

The improved analytics capabilities of universal links, makes them a versatile tool for marketers. For instance, they can use universal links for accurately attribute and reattribute events.

Deep Linking Definition

Deep linking was the standard method for iOS apps. App developers implemented Uniform Resource Identifiers (URI) schemes to simplify the path of linking users directly to a destination inside the app.

For example, fb:// opens the Facebook app, and when adding profile details, it can direct the user to a specific profile.

The problem with deep links is that they work great when the app is installed on the user’s phone.

But if the user doesn’t have the app installed, it shows the user a “Cannot open Page”, prompt in Safari, which impacts the user experience, as shown in the diagram below.

Universal Linking vs. DeepLink Differences

Universal Linking Definition

Universal links and app links are two powerful technologies that allow app developers to easily link their apps with web pages or other apps. These links offer a seamless user experience by directly taking users to the relevant content within the app or website, without the need for a web browser or a separate app.

Universal links are routed directly by the operating system, associating the app and the web page securely. The goal of universal links is to improve the user experience, whether the user has the app installed or not, creating a more secure connection between the web and the app.

Deep Linking vs. Universal Linking 

Despite deep and universal links similarities, they have key differences. Let’s start by defining them:

A deep link links to a specific section within an application, such a specific page. 

A universal link, works similarly to deep links but for iOS device, so Apple users can navigate directly to a specific point on an application.

There are several advantages to universal links, such as enhanced security features. Another advantage is that an universal link can be shared across multiple platforms and devices, while a deep link uses a custom URL which only works within a specific app.

Here is a summary of the main differences between Universal Links and Deep Links.

Universal Links
Match a webpage to an in-app location.
Exclusive to Apple devices
Works regardless the app is installed on the user’s device or not.
Uses a web URL
Doesn’t support redirects
Not suitable for email marketing
Not suitable for social media
Deep Links
You can only use it within a specific app.
Doesn’t work if the app is not installed on the user's device.
Uses a custom URL scheme
Can redirect
Can be used in email marketing
Can be used in social media

How to create and set up a Universal Link 

Different platforms may have different dashboards to create universal links. On a high level, here are the basic steps to get universal linking working for your app. 

1. Set your app to register approved domains 

  1. Register your app with Apple at developer.apple.com
    • Log in to developer.apple.com.
    • Click on Certificates, Identifiers & Profiles. Then, on Identifiers.
    • If you have an App Identifier, follow to the next section. If not, click on the + sign and fill out the form.
  2. Allow Associated Domains on the app identifier.
  3. Allow Asociated Domains on your Xcode project.
    • Make sure your Xcode project has the same Team selected as your App Identifier.
    • Go to the Capabilities tab and choose your project file
    • Enable Associated Domains. Check your Bundle Identifier for your project matches the one registered with your App Identifier.
  4. Add the right domain entitlement. Ensure the entitlement file is included at build
    • Prefix applinks: to your domain tag.

2. Set your website to host the apple-app-site association

  1. Buy or use your existing domain name
  2. Purchase the SSL certification for the domain
    • Go to a third-party service and fill out the form to generate an openSSL command.
    • Log into your remote server
    • Execute the OpenSSL command and generate a certificate signing request (.csr) and certification file (.cert)
  3. Create the apple-app-site-association JSON file.
  4. Sign the JSON file with the SSL certification.
  5. Configure the file server.

Setting up on iOS

Add the following in AppDelegate.m file so the app can listen to the incoming universal links.

// Add the header at the top of the file for RCTLinking:

#import

// Add this above the `@end`:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url

 options:(NSDictionary<uiapplicationopenurloptionskey,id> *)options</uiapplicationopenurloptionskey,id>

{

 return [RCTLinkingManager application:app openURL:url options:options];

}

// Add this above `@end` for Universal Links:

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity

 restorationHandler:(nonnull void (^)(NSArray<id> * _Nullable))restorationHandler</id

{

 return [RCTLinkingManager application:application

 continueUserActivity:userActivity

  restorationHandler:restorationHandler];

}

Once you add the scheme to your Xcode project configuration, you need to setup the Associated Domains  on your server

Run the following JSON code for an example of a simple association file:

{

"applinks": {

"details": [

 {

"appIDs": [ "ABCDE12345.com.example.app", "ABCDE12345.com.example.app2" ],

"components": [

 {

"#": "no_universal_links",

 "exclude": true,

"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"

   },

   {

"/": "/buy/*",

  "comment": "Matches any URL whose path starts with /buy/"

       },

       {

         "/": "/help/website/*",

       "exclude": true,

      "comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"

       },

      {

     "/": "/help/*",

     "?": { "articleNumber": "????" },

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

        }

      ]

      }

    ]

  },

  "webcredentials": {

 "apps": [ "ABCDE12345.com.example.app" ]

  },

   "appclips": {

 "apps": ["ABCED12345.com.example.MyApp.Clip"]

   }

}

Setup on Android

Setting up on Android

Configuring external linking in Android requires to make changes to the manifest file. To do that:

  1. Open android/app/src/main/AndroidManifest.xml file:
  2. Go to MainActivity/launchmode and choose the setting to singleTask
  3. Inside the MainActivity, select VIEW and add a new intent-filter
  4. Ensure your new has an android:autoVerify=”true”
  5. Add a new entry inside the with your domain’s URL scheme and host.

<activity

    android:name=".MainActivity"

    android:launchMode="singleTask">

    <intent-filter android:autoVerify="true">

        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />

    </intent-filter>

    <intent-filter>

        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />

        <category android:name="android.intent.category.BROWSABLE" />

        <data android:scheme="your_URI_scheme" />

        <data android:scheme="https" android:host="your_URL" />

        <data android:scheme="http" android:host="your_URL" />

    </intent-filter>

</activity>

How to Test Universal Links

Let’s explain it better with an example:  imagine you create a React Native application. How do you test the universal links on iOS? Source

1. Open prompt and run the following code:

npx react-native init react_native_deep_links_master

Cd react_native_deep_links_master

2. Create the RootNavigation.js file using the following code:

import * as React from 'react’;

export const navigationRef = React.createRef();

export function navigate(name, params) {

navigationRef.current?.navigate(name, params);

}

3. Build an app in React Native containing two screens. Open the App.js file and enter the following code:

import React, {useEffect} from 'react';

import {View, Text, Button, Linking, Alert} from 'react-native';

import {NavigationContainer} from '@react-navigation/native';

import {createStackNavigator} from '@react-navigation/stack';

import * as RootNavigation from './RootNavigation';

function HomeScreen({navigation}) {

  return (

   

     Home Screen

    <button< code=""></button<>

    title="Go to Details"

   onPress={() => navigation.navigate('Details')}

  />

  );

}

function DetailsScreen() {

  return (

  Details Screen 

 );

}

const Stack = createStackNavigator();

function App() {

 const linking = {

  prefixes: ['https:', '://'], //to configure react navigation to handle the incoming links

  };

  useEffect(() => {

   // Get the deep link used to open the app

   const getUrl = async () => {

   const initialUrl = await Linking.getInitialURL();

    if (initialUrl === null) {

      return;

    }

    if (initialUrl.includes('Details')) {

  Alert.alert(initialUrl);

     RootNavigation.navigate('Details');

    }

   };

 getUrl();

 });

  return (   

  );

}

export default App;

4. Configure the React Navigation and the dependencies.

yarn add @react-navigation/native @react-navigation/native-stack

react-native-screens react-native-safe-area-context

Testing on iOS

1. Check your app allows Associated Domains 

Allowing associated domains enable the app to listen to incoming universal links requests. Follow the steps in the above section to enable this feature in your app Xcode project.

2. Set up a Digital Asset Links  JSON file, like the following example:

[{

"relation": ["delegate_permission/common.handle_all_urls"],

 "target": {

 "namespace": "android_app",

  "package_name": "com.example",

"sha256_cert_fingerprints":

["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1

D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]

  }

}]

3. Run the following command:

npx react-native run-ios

4. Test Universal Links Using Safari

According to the Apple’s developer forum, there are a few methods to test the universal link before releasing the application using Safari.

  • You can simply embed the link in any webpage and then access the page from the Safari browser. If it opens the link then it works.
  • If the application has a banner that shows up when scrolling, you can use that banner to enable universal links for the user.

There are limitations to testing universal links in Safari. For instance, you cannot use Safari wrappers to test universal links on some devices.

5. Test Universal Links Using Xcode Simulator 

Until 2019, universal links wouldn’t work in the simulator, but could be tested from a device. Now you can use the User Interface Testing, released with iOS 9. Because universal links don’t work unless a user clicks on the link, it can be frustrating to try to test this in the simulator, so typing the link into Safari or redirecting with javascrip won’t open the application. But there is a simple workaround.

  1. Open the simulator’s iMessage app
  2. Select a contact and open up a chat
  3. Type the URL into the message bar and send the message
  4. Click the message bubble.
  5. The universal link should open the app.

Testing On Android

1. Technically, there are no universal links in Android: 

Universal links are an Apple’s exclusive feature. Android has App Links, which behave similarly to universal links. Before testing universal links on Android, you should ensure your application can handle the incoming requests for universal links. As we mentioned above, the intent filters must include your domain scheme and host for the app’s universal links.

2. Test Universal Links Using Chrome:
Once your app’s intent filters are properly configured, you can test universal links on Android using Chrome. While universal links work when opened in Safari or Chrome, they don’t work if  you enter the universal link in the Chrome address bar and press Enter. You should host the links in a web environment to test them.

Start by creating a testing page in HTML, the follow these steps:

  • Add your complete universal link to the test webpage
  • Install the app in the test device
  • On the test device open the test web page from Chrome
  • Click the universal link.
  • If the link is configured correctly, your app should launch and take you to the relevant content.

3. Tips to debug Android App Links 

  •  To debug your universal link for an Android app, first you need to ensure the device browser is not the default handler for the app link. If the user clicks the link before app links are enable, they have the option to select where they want to open the link, if they choose to open in browser “always”, the domain will not open the app, ever.
  • If this happens, you can reset browser to default by following this path: Settings/Apps/select browser/defaults/”Clear Defaults”.
  • All domains should pass verification. If you don’t have autoVerify=”true” in all intent filters, Android will verify all domains, and if one domain fails verification, App Links will be disabled for the rest.

4. Test Universal Links Using ADB: 

You can also test universal links on Android using the Android Debug Bridge (ADB). To do this, connect your Android device to your computer, open a command prompt, and enter the following command: “adb shell am start -a android.intent.action.VIEW -d universal-link-url”. Replace “universal-link-url” with the actual universal link you want to test. If the link is configured correctly, your app should launch and take you to the relevant content.

Other Tips to test universal links

  • Test the link on different channels. Not only on the web but also in social media, SMS, and messaging platforms.
  • Keep in mind that universal links only work when clicked on.
  • When testing, ensure the app is installed on the devices you will be testing.

Universal links have limitations too.

They are not Universal

The way that Apple implements Universal Links forced social media platforms such as Twitter, Pinterest, and Facebook to significantly change how they handle external links.

Currently, these apps intercept the link and open with an internal review to track the user’s web activity. A universal link must send the user externally, losing their track capabilities.

So, if you want to use universal links in social media, you must work around deep linking with legacy methods. Apple builds most apps that support universal links.

You can’t use universal links for email campaigns.

Many organizations use email to interact with their users and as a marketing tool. Tools like MailChimp or Sendgrid are commonly used to handle the volume of email campaigns. They provide services such as click-tracking, where they wrap the original link in a redirect so the user goes to the provider’s server before the final destination. That’s where the problem lies with universal links. You cannot wrap a universal link in a redirect.

Users can disable them.

It is simple to disable Universal links on the phone. Click the domain name in the top right-hand corner after clicking a universal link. If you do that, it opens the link in safari and permanently disables universal links from the device.

Universal links are complicated to debug and test.

Debugging a feature is an essential part of development. However, debugging universal links is a 7-step process involving configuring the web server, the native app project, and the developer portal. With many steps along the way, the chances of mistakes are increased. And even when there are several ways a universal link can break, Apple doesn’t have a validator tool to help with debugging.

Phantom Banners

This is a known Safari issue. Apple may randomly install a banner into your site in Saari when you enable universal links. You cannot control this, customize it or measure it. While most users just ignore this, it can be annoying.

Why allow apps to Link to your content?

Despite its limitations, allowing universal links has several benefits.

  • Improve customer experienceUniversal links take the user straight to the in-app content instead of having the user install the app and then find the content they are looking for. By doing that, they create a seamless user experience.
  • Increase app conversions.When users get to what they want right away, they are satisfied and happy users tend to make purchases. Therefore, the improved customer experience often leads to a boost in conversion rates.
  • Increase retention rates.Finally, the improved experience results in higher user engagement and retention rates.
  • Provide a secure path for users.
    Universal links can prevent malicious actors from hijacking links and redirecting users to fraudulent applications.

Why a Universal Link Improves the performance of your app

Implementing universal links may take some time and effort to implement, but if you can do it, it will ultimately improve performance:

1. Universal links can fall back to the store if the app opening breaks

Universal links are a feature that can be used in conjunction with MMPs to redirect users to the App Store to prompt an app install if an app-open trigger fails to launch  This is a big plus for mobile-first advertisers who want users to re-engage in their app. The user flow for universal links significantly improved from URL schemes and deep links where the user would have arrived at a dead-end when the URL scheme failed to respond.

While a fallback was also possible for URL schemes in the past, Apple has since removed that feature. Therefore, universal links are now the preferred method for redirecting users to an app from a website.

While having a mobile website is still beneficial for mobile-first advertisers, it is no longer required to redirect users to the App Store. Universal links have made it possible to redirect users directly to the App Store without needing a mobile website.

However, it is still recommended that advertisers have a mobile website to provide a better user experience and to attract potential customers who may not have the app installed yet.

  • They are necessary for re-engaging users

When deep links bring the users back from an ad into your app, the links prompt a pop-up message on the user’s screen, impairing the user experience and performance. By directing the user straight to the app content, universal links prevent this. 

  • Improves re-attributions accuracy and decreases rejected re-attributions

A re-attribution is an association between a click and an open application such as the future in-app events happening after the click will be attributed to the advertising party that delivered that last click. If the app open happens after a given time frame,  a mobile measurement partner usually rejects the reattribution. Because universal links create a smooth flow, the number of rejected re-attributions decreases.

FAQS

What does a universal link look like?

Universal links look like regular HTTPS URLs. When the user clicks on it, the device opens the app in the content of the link directed to.

How do I set up Universal links for my app?

There are two basic steps:

  1. Set your app to register approved domains at the developer. Apple.com
  2. Configure your website so it can host an apple-app-site-association file.

Why don’t universal links sometimes work as tracking links?

Link-wrapping is not supported by universal linking, meaning you cannot wrap the link with a link redirect. Therefore, universal links sometimes fail as tracking links.

Is the universal link only on iOS?

Apple created these links protocols for launching apps on iOS from any website; therefore, are iOS-specific.

How do I reset my iOS for universal linking? 

Long press on a universal link and it will take you to a message with an “open in `AppName`” option. Select the option to set opening the links in your app again.