To enable Universal Links on iOS and App Links on Android, you need to host two specific JSON files

To enable Universal Links on iOS and App Links on Android, you need to host two specific JSON files on your web server:

Intermediate

To enable Universal Links on iOS and App Links on Android, you need to host two specific JSON files on your web server:

  1. apple-app-site-association (AASA) for iOS: This file tells iOS which paths on your website should be handled by your iOS app.
  2. assetlinks.json for Android: This file tells Android which paths on your website should be handled by your Android app.

Serving these files correctly is crucial for deep linking to work seamlessly.

1. Hosting the apple-app-site-association (AASA) File for iOS

  • File Content: The AASA file is a JSON file that maps your website's paths to your app. A common structure looks like this:

    json { "applinks": { "apps": [], "details": [ { "appID": "TEAM_ID.com.yourcompany.yourapp", "paths": [ "/app/*", "/links/to/content/*", "*" ] } ] } } * Replace TEAM_ID.com.yourcompany.yourapp with your app's unique identifier (Team ID followed by your app's bundle ID). * The paths array specifies which URL paths on your website should be handled by the app. "*" means all paths.

  • Hosting Requirements:

    • Location: The file must be hosted at the root of your domain or in the .well-known directory. For example:
      • https://yourdomain.com/.well-known/apple-app-site-association
      • https://yourdomain.com/apple-app-site-association (less common now)
    • HTTPS: The file must be served over HTTPS.
    • MIME Type: The Content-Type header should be application/json or application/json; charset=utf-8.
    • No Redirects: The AASA file itself should not be redirected.
  • Verification: iOS devices download this file when your app is installed. You can test its accessibility using the Apple Validation Tool or by simply trying to access the URL in Safari.

2. Hosting the assetlinks.json File for Android

  • File Content: The assetlinks.json file contains information about your app and the website it's associated with.

    json [ { "relation": [ "delegate_permission/common.handle_all_urls" ], "target": { "namespace": "android.app", "package_name": "com.yourcompany.yourapp", "sha256_cert_fingerprints": [ "YOUR_APP_SHA256_FINGERPRINT" ] } } ] * Replace com.yourcompany.yourapp with your app's package name. * Replace YOUR_APP_SHA256_FINGERPRINT with the SHA256 fingerprint of your app's signing certificate (you can get this from your keystore or build tools).

  • Hosting Requirements:

    • Location: The file must be hosted at https://yourdomain.com/.well-known/assetlinks.json. The .well-known path is mandatory.
    • HTTPS: The file must be served over HTTPS.
    • MIME Type: The Content-Type header should be application/json or application/json; charset=utf-8.
  • Verification: Android devices check this file to verify the association. You can use the Google Asset Link API Validator to check your assetlinks.json file.

3. Server Configuration Best Practices

  • Static File Serving: Configure your web server (e.g., Nginx, Apache, or your cloud provider's static hosting service) to serve these JSON files directly.
  • Caching: Be cautious with caching these files. While caching can improve performance, it can also delay the propagation of changes if you update your app or website association. It's often recommended to set a short cache duration or disable caching for these specific files.
  • Content Type: Ensure the correct Content-Type header is set.
  • Accessibility: Make sure these files are publicly accessible without requiring authentication.

By correctly hosting these association files, you enable Universal Links and App Links, providing a smoother and more integrated experience for your users.