App link and Deep link in Android and iOS

Apurva Kanthraviya
Simform Engineering
7 min read4 days ago

Simplifying redirection to your app by clicking on the web URL

While building our app, we realized the potential of redirecting users directly to our app through a simple URL click. This approach not only enhances user convenience but also helps grow our app’s user base. App links and deep links make this possible by enabling seamless navigation to specific app sections directly from a URL. Let’s dive deeper into how App Links and Deep Links work for Android and iOS.

Android:

  • App link: Introduced in Android 6.0, app links use HTTP or HTTPS URLs to direct users to specific content within your app. This requires a digital asset links file in the website’s root folder.
  • Deep link: Compatible with any Android version, deep links support HTTP, HTTPS, or custom URL schemes.

iOS:

  • Universal link: Introduced in iOS 9, similar to Android app links. Universal links need an AASA (apple-app-site-association) file to allow secure communication between iOS apps and their associated websites.
  • Custom URL scheme: Available from iOS 13 onwards, similar to deep links in Android.

App link / Universal link: https://your-domain-name

Deep link / Custom URL scheme: your-scheme://your-domain-name

Let’s start with the app link setup for Android.

Step 1: Define intent, host and your domain in AndroidManifest.xml

  • To set up app links for Android, you need to add an intent-filter to your AndroidManifest.xml file.
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="yourDomain.com" />
</intent-filter>
  • autoVerify: Android OS can verify the domain when the app is installed or updated. When set to true, the Android system tries to verify all associated host URLs in the intent-filter.
  • action.VIEW: This allows you to start an activity in another app.
  • category.DEFAULT: The default category of an intent. It is mainly used for implicit intents. If your app wishes to be started by implicit intents, it includes this category.
  • category.BROWSABLE: If a user clicks on a link in a webpage or email, the intent generated to execute that link will require the BROWSABLE category.
  • scheme and host: A URI scheme is a URL that takes users directly to the app when a user clicks on a link.
  • Refer to the Android official documentation for detailed guidance on using different elements in the data tag.

Step 2: Create theassetlinks.json file

  • When installing the app, the system verifies the associated URLs that the app supports. To set this up, you need to create a digital asset links JSON file on your website. This file indicates the Android apps that are associated with the website and verifies the app’s URL intents.
  • Note: This step is only necessary for HTTP/HTTPS links, not for custom schemes.

Steps to Create assetlinks.json:

  1. Create the JSON File:
  • Name the file assetlinks.json.
  • This file includes digital asset links that associate your site with your app.

2. Structure of assetlinks.json:

  • Replace com.example with your package name.
  • Replace sha256_cert_fingerprints with your app’s unique SHA-256 certificate fingerprint.
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example",
"sha256_cert_fingerprints":
["00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"]
}
}]

Upload the file:

  • Upload the assetlinks.json file to your website’s root folder.
  • The file must be located at https://your-domain/.well-known/assetlinks.json.
  • By following these steps, you will successfully link your app with your website, allowing the system to verify and handle your app’s URL intents.

Step 3: Verify the assetlinks.json File Configuration.

  • To ensure the assetlinks.json file is correctly set up, you need to test it. Here’s how to check if the file is successfully configured:
  • You can test it using a statement list generator and tester. Generate the SHA-256 of your app with the following command:
keytool -list -v -keystore <keystore path> -alias <key alias> -storepass <store password> -keypass <key password>
  • The above command will only give sha256. If you have signed up for your app on Google Play Console, then you can find it in Developer Console at Setup > App Integrity > App Signing.

Step 4: Test the app link on the Android emulator.

  • Note: On Android 11 (API level 30) and lower, the system establishes your app as the default handler for the specified URL patterns only if it finds a matching Digital Asset Links file for all hosts in the manifest.
  • To test if the app link is successfully set, run the following command in the terminal:
adb shell am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "http://your-domain-name:port_optional"

Common Issues and Troubleshooting:

  • Dialog with Multiple Apps: If clicking on a link opens a dialog showing multiple apps instead of directly opening your app, it indicates a configuration issue. Ensure android:autoVerify="true" is present in the manifest.
  • Verification of assetlinks.json File: If the app link still does not work as expected, review the assetlinks.json file. Check for correct sha256_cert_fingerprints and any spelling mistakes.
  • Google Cache Issue: Sometimes, Google may cache the content of a file. Old statements may take up to two days to flush out all the caches(reference). You can check the cached SHA-256 key by modifying the URL below:
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://www.your-website-name.com&relation=delegate_permission/common.handle_all_urls
  • Android 12 and Higher: On Android 12 and higher, if the digital asset links file is not properly placed at the host URLs, clicking a link will always open it in the browser instead of the app.

Setting Up Universal Links for iOS

Step 1: Setup associated domain.

Open Your Xcode Project:

  • Go to Project_name > Signing & Capabilities.

Enable Associated Domains:

  • Click + Capability and select Associated Domains.

Add Your Domain:

  • Add applinks:your-domain-name.com under Associated Domains.

Step 2: Create the apple-app-site-association file

  • For iOS, you need to set up the AASA (apple-app-site-association) file, similar to the assetlinks.json file for Android. Place this file at .well-known/apple-app-site-association in your website's root directory.

Structure of AASA File:

  • paths: An array of strings specifying which paths to include in associations. Paths are case-sensitive, and query strings and fragment identifiers are ignored. Use "*" to include all paths.
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TEAM_ID.bundleID",
"paths": [ "/path/to/content/*" ]
}
]
}
}
  • Replace TEAM_ID with your Apple Developer Team ID and bundleID with your app's bundle identifier.

Upload the File:

Validation:

Step 3: Test the universal link

  • To test the universal link for development purposes, you can do it by enabling Associated Domains Development in Settings> Developer.
  • Note: After setting up, changes to the AASA file may take about a week to apply because the system checks associated domains only at app installation and once a week. You can find more about this in the official documentation.
  • Test the Universal Link on the iOS Simulator with the following commands:
  • Universal link:
xcrun simctl openurl booted https://yourDomain.com/path
  • Custom URL scheme:
xcrun simctl openurl booted yourScheme://yourDomain.com/path

Important Note on Universal and Dynamic Links

Universal Links and App Links Behaviour:

  • When a user clicks on a link and the app is installed, the app opens.
  • If the app is not installed, the URL opens in the browser.
  • These links do not direct users to the Play Store or App Store for app installation.

Dynamic Links:

  • To handle cases where the app is not installed, use Firebase Dynamic Links.
  • Dynamic Links can redirect users to the Play Store or App Store if the app is not installed and open the app if it is.
  • For more details on setting up dynamic links using Firebase, refer to the official Firebase documentation.
  • Firebase Dynamic Links will be deprecated on August 25, 2025.
Universal link and App link
Dynamic-link

Alternative Services for Dynamic Links:

https://your-subdomain.dynalinks.app/path1
https://your-subdomain.dynalinks.app/path2

Conclusion

In this blog, we explored App Links and Deep Links for Android and iOS, guiding you through the setup process. Implementing these features enhances user experience by enabling seamless navigation, improving engagement, and growing your user base. Whether linking to content within your app or directing users from external sources, mastering these links is key to a connected, user-friendly app.

--

--

Simform Engineering
Simform Engineering

Published in Simform Engineering

Our Engineering blog gives an inside look at our technologies from the perspective of our engineers.

No responses yet