iOS Universal Links/ Android App Links

Preetha Ajayan
3 min readSep 9, 2020

--

Allows your website URL to open the content in your Mobile App

When the user taps on your website HTTPS link on a Phone and be sent directly to your mobile App if App is installed in the phone.

If App isn’t installed, tapping the URL opens website in browser .

iOS Universal links and Android App links work by providing a small file (served over HTTPS) from the root of a web domain that points to a specific App ID and then registering that specific app ID with Apple/Android as handling links from that domain.

To accomplish this, we need to do three things

  1. Configure the Mobile App — Inform the App about the web site
  2. Configure the Website — Inform the web site about the App
  3. Handle the navigation within the App whenever the user taps a link.

Step 1 : Configure the Mobile App.

For iOS,

  1. Select your iOS project.
  2. Select the target.
  3. Select the Capabilities tab.
  4. Turn on Associated Domains.
  5. Add the web domain: — applinks:<domain name>

For Android, add intent filter that contains elements and attribute values in manifest file such as <action>,<data>,<category> etc..

  1. Action: android.intent.action.VIEW
  2. Categories: android.intent.category.BROWSABLE and android.intent.category.DEFAULT
  3. Data scheme: http or https , <data android:scheme=”http” android:host=”www.domain.com" />

Step 2 : Configure the Web site

To create a secure connection between the website and the Mobile App, establish a trust relationship between them. This can be established by publishing the apple-app-site-association(iOS) and Android Digital Asset Links (assetlinks.json) to HTTPS webserver

  1. iOS — Create a new file called apple-app-site-association. (The format matches that of a JSON file, but it CANNOT have the .json extension)

Place the file at the root directory or at the .well-known subdirectory. (‘write access’ to the web site is required top upload the file)

https://<your-domain>/apple-app-site-association

or

https://<your-domain>/.well-known/apple-app-site-association

2. Android — Create Digital Asset Links JSON file and upload the file in the webserver in the below location. Digital Asset Links JSON file used to indicate the Android app that are associated with the website.

https://your-domain.name/.well-known/assetlinks.json

After the above 2 steps the Mobile App and Website are officially aware of each other.

Step 3: Handle the navigation within the App whenever the user taps a link.

Handle the navigation from webpage links via UIApplicationDelegate methods for iOS.

(Specifically application:continueUserActivity:restorationHandler: ) , where your mobile App can receive a link and handle it properly.

In case of Android you can handle the navigation from webpage links via Intent.

(specifically onNewIntent method) , where Mobile App can receive a link and handle it properly.

{
"applinks": {
"apps": [],
"details": [
{"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths":
[ "/wwdc/news/","/videos/wwdc/2015/*"]
},{"appID": "ABCD1234.com.apple.wwdc",
"paths": [ "*" ]
}
]
}
}

applinks : — tag determines which apps are associated with the web site.

apps : — leave as an empty array

details : — array of dictionaries for linking appIDs and URL paths.

appID — unique identifier of the Mobile App.

The appID consists of your team ID combined with the app’s bundle ID.

*TeamID and App Bundle Id will be available from Apple Developer Account and subject to changes as per configurations.

* wildcard character to associate all of the web site’s links. We can limit the paths value to specific folders or file name.

Sample for Android Digital Asset Link file (assetlinks.json)

The below file grants link-opening rights to a com.example Android App.

[{“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:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"] }}]

package_name : — is the unique Application ID declared in the App’s build.gradle file

sha256_cert_fingerprints :- The SHA256 fingerprints of your app’s signing certificate.

!!! HAPPY LEARNING !!!

--

--