# Configuring Server 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:

<pre class="language-json" data-title="apple-app-site-association"><code class="lang-json"><strong>{
</strong>  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "&#x3C;TeamID>.&#x3C;BundleID>",,
        "paths": [
          "*"
        ]
      }
    ]
  }
}
</code></pre>

* 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.

### Android Digital Asset Links (`assetlinks.json`)

**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:

{% code title="assetlinks.json" %}

```json
[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "your.app.package",
      "sha256_cert_fingerprints": ["<SHA256_Fingerprint>"]
    }
  }
]
```

{% endcode %}

* 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.html`using a text editor.

**2. HTML Structure:**

* The `redirection.html` file should contain the following structure:

{% code title="redirection.html" %}

```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>

```

{% endcode %}

* 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.

<figure><img src="https://4128853559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDytDSBRx8P4ZZXD57DA%2Fuploads%2FbV3hJtDnFdwb6ThNIy8p%2Fimage.png?alt=media&#x26;token=0a2f0d66-a5ae-4feb-a6d7-14168e8ea9f2" alt=""><figcaption></figcaption></figure>

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

{% embed url="<https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content>" %}
iOS allowing apps and websites to link to your content
{% endembed %}

{% embed url="<https://developer.android.com/guide/navigation/design/deep-link>" %}
Android deep linking
{% endembed %}

### Verifying Deep Link Setup

To verify that your deep link setup is working correctly, you can use Branch's ["Associated Domains" validation tool](https://branch.io/resources/aasa-validator/) to test your `apple-site-association` file and follow this [developer guide](https://developer.android.com/training/app-links/verify-android-applinks) for your `assetslinks.json` file.
