Configuring Server Files

Configuring apple-app-site-association, assetlinks.json, and the redirection.html files

Mobile app deep linking enables seamless navigation between web pages and app content, enhancing the user experience and engagement. To implement deep linking on iOS (using apple-app-site-association), Android (using assetlinks.json) and the app redirect (using redirection.html), follow the instructions below.

Apple App Site Association (apple-app-site-association)

1. Create the File:

  • Create a JSON file named apple-app-site-association (with no file extension) using a text editor.

2. JSON Structure:

  • The apple-app-site-association file should contain a JSON object with the following structure:

apple-app-site-association
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "<TeamID>.<BundleID>",,
        "paths": [
          "*"
        ]
      }
    ]
  }
}
  • Replace <TeamID> with your Apple Team ID and <BundleID> with your app's Bundle ID.

3. Specify Associated Domains:

  • In your Xcode project, go to the "Signing & Capabilities" tab.

  • Enable the "Associated Domains" capability.

  • Add the domain(s) and paths that you want to associate with your app using the applinks:<domain> format.

4. Add the File to the Server:

  • Place the apple-app-site-association file at the root of your domain (e.g., https://www.yourdomain.com/.well-known/apple-app-site-association).

5. Test Universal Links:

  • Deploy your app on a testing device through TestFlight or other testing methods.

  • Ensure the app is associated with the correct domain and paths.

  • Open a link that matches the specified domain and path on your testing device. It should open the app directly to the specified content.

1. Create the File:

  • Create a JSON file named assetlinks.json using a text editor.

2. JSON Structure:

  • The assetlinks.json file should contain a JSON array with the following structure:

assetlinks.json
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "your.app.package",
      "sha256_cert_fingerprints": ["<SHA256_Fingerprint>"]
    }
  }
]
  • Replace your.app.package with your Android app's package name.

  • Obtain the <SHA256_Fingerprint> by running the following command:

  • keytool -list -v -keystore your_keystore.keystore

3. Add the File to the Server:

  • Place the assetlinks.json file at the root of your domain (e.g., https://www.yourdomain.com/.well-known/assetlinks.json).

Redirecting to the Apple App Store & Google Play Store (redirection.html)

1. Create the File:

  • Create a JSON file named redirection.htmlusing a text editor.

2. HTML Structure:

  • The redirection.html file should contain the following structure:

redirection.html
<html>
<head>
   <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
</head>
<body>

<script>
    const getMobileOS = () => {
        const ua = navigator.userAgent;
        let redirectUrl;
        
        const androidUrl = "https://play.app.goo.gl/?link=https://play.google.com/store/apps/details?id=your.app.package";
        const iOSUrl = "https://apps.apple.com/us/app/your-app-name/id123456789";
        const nonMobileUrl = "https://www.arway.ai/";
        
        if (/android/i.test(ua)) {
            redirectUrl = androidUrl;
        } else if (/iPad|iPhone|iPod/.test(ua)) {
            redirectUrl = iOSUrl;
        } else {
            redirectUrl = nonMobileUrl;
        }
        
        setTimeout(() => {
            window.location.href = redirectUrl;
        }, 3000);
    };
    
    getMobileOS();
</script>

</body>
</html>
  • Replace the variables androidUrl and iOSUrl with your own app store links.

  • Replace the variable nonMobileUrl with a fallback link in the case that someone is opening the link from a non-mobile device.

3. Add the File to the Server:

To achieve the desired behavior where any URL in the format of https://qr.yourdomain.com/{*} is redirected to the "redirection.html" file, you need to set up server configuration rules.

Keep in mind that the implementation specifics may vary depending on the web server you are using (e.g., Apache, Nginx) and the server-side scripting language (e.g., PHP, Node.js) you have at your disposal. The redirection can be achieved through server configuration files or using server-side code to handle the redirection logic.

Additional Path Parameters

Path parameters in deep linking simplify user access by directing them to specific content or features within apps, aiding personalization and tracking. They enhance sharing and engagement, offering a seamless experience.

Include paths in the Deeplink Domain on the 'For Developers' page of the Creator Portal if you want to add these extra path parameters.

More information on path parameters for deep links can be found below.

To verify that your deep link setup is working correctly, you can use Branch's "Associated Domains" validation tool to test your apple-site-association file and follow this developer guide for your assetslinks.json file.

Last updated