To correctly serve iOS and Android App Link files, you need to configure both your website and your mobile applications. This involves creating and hosting specific files on your web server and making corresponding configurations within your iOS and Android projects.
iOS Universal Links
For iOS, you need to set up Universal Links, which allow users to tap a link to your website and be seamlessly redirected to your installed app.
-
Create the
apple-app-site-associationfile:- Create a JSON file named
apple-app-site-association(without a.jsonextension). - This file declares which URLs your app can handle.
- The file should contain an
applinksdictionary. Insideapplinks, include an emptyappsarray and adetailsarray. Each object in thedetailsarray should specify theappID(your Apple Team ID followed by your app's Bundle Identifier) and an array ofpathsthat your app can handle. You can use wildcards (*and?) for path matching. - Example
apple-app-site-associationcontent:json { "applinks": { "apps": [], "details": [ { "appID": "YOUR_TEAM_ID.com.yourcompany.yourapp", "paths": [ "/path/to/content/*", "/another/path/*", "NOT /path/to/exclude" ] } ] } }
- Create a JSON file named
-
Host the file on your web server:
- The
apple-app-site-associationfile must be hosted at the root of your domain or within the.well-knownsubdirectory (e.g.,https://yourdomain.com/apple-app-site-associationorhttps://yourdomain.com/.well-known/apple-app-site-association). - It must be served over HTTPS with a valid SSL certificate.
- The file must be accessible directly without any HTTP redirects (301 or 302).
- The MIME type for the file should be
application/json. - The uncompressed file size should not exceed 128 KB.
- If you support multiple domains or subdomains, each domain needs its own
apple-app-site-associationfile.
- The
-
Configure your iOS app:
- In Xcode, enable the "Associated Domains" capability for your project.
- Add the domains your app will support to the "Associated Domains" list, prefixed with
applinks:(e.g.,applinks:yourdomain.com). - Implement the necessary methods in your app's
AppDelegateorSceneDelegateto handle the incoming Universal Link URLs.
Android App Links
For Android, App Links provide a similar seamless experience, allowing verified links to open directly in your app without a disambiguation dialog.
-
Create the
assetlinks.jsonfile:- Create a JSON file named
assetlinks.json. - This file establishes a trusted association between your website and your Android app.
- The file should contain a JSON array with an object that specifies the
relation(e.g.,delegate_permission/common.handle_all_urls),target(includingnamespaceasandroid_app, your app'spackage_name, and thesha256_cert_fingerprintsof your app's signing certificate). - You can obtain the SHA256 fingerprint using the
keytoolcommand or from the Google Play Console if you use Play App Signing. - Example
assetlinks.jsoncontent:json [{ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", "package_name": "com.yourcompany.yourapp", "sha256_cert_fingerprints": ["AA:BB:CC:DD:EE:FF:11:22:33:44:55:66:77:88:99:00:11:22:33:44:55:66:77:88:99:00:AA:BB:CC:DD:EE:FF"] } }]
- Create a JSON file named
-
Host the file on your web server:
- The
assetlinks.jsonfile must be hosted athttps://yourdomain.com/.well-known/assetlinks.json. - It must be served over HTTPS with a valid SSL certificate.
- The file must be accessible directly without any HTTP redirects (301 or 302).
- The MIME type for the file should be
application/json. - If your app links support multiple host domains, you must publish the
assetlinks.jsonfile on each domain.
- The
-
Configure your Android app:
- Add an
<intent-filter>to your app'sAndroidManifest.xmlfor the URLs you want to handle. - Include
android:autoVerify="true"in the<intent-filter>. This tells Android to verify the host domain. - The
<intent-filter>should includeACTION_VIEW,BROWSABLE, andDEFAULTcategories. - Specify the
<data>scheme (e.g.,https), host, and any optional path prefixes or patterns. - Example
AndroidManifest.xmlintent-filter:xml <activity android:name=".MainActivity"> <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" android:host="yourdomain.com" android:pathPrefix="/path/to/content" /> </intent-filter> </activity> - Handle the incoming
Intentin your app's activity to extract data from the URL and navigate to the appropriate content.
- Add an
General Best Practices
- HTTPS is mandatory for both iOS Universal Links and Android App Links.
- Avoid redirects when serving these association files.
- Test thoroughly on real devices and use validation tools (e.g., Google's Digital Asset Links API for Android, and various online validators for iOS AASA files) to ensure correct setup.
- Ensure you own the domains for which you are configuring app links.