> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://amer.developers.trustly.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://amer.developers.trustly.com/_mcp/server.

# Set up App Links

Android App Links are a Beta feature. Functionality is subject to change as Trustly continues to make improvements. To enable this feature or request assistance, contact [Trustly Support](mailto:us.support@trustly.com).

[Android App Links](https://developer.android.com/training/app-links) allow seamless integration between your website and your Android application. By using standard HTTP or HTTPS links, you ensure that users are directed to specific content within your app without the need for browser redirects or system prompts.

Unlike custom URL schemes, App Links provide a reliable fallback strategy: if the application is not installed, the link functions as a standard web link and directs the user to your site. This guarantees the link resolves to the correct content, regardless of whether the app is installed.

Android recommends App Links as the primary method for deep linking due to their security and usability advantages over legacy URL schemes.

The following table compares the features and behavior of App Links versus custom URL schemes.

| Feature         | Android App Links                                                                                                       | Custom URL Schemes                                                                                     |
| :-------------- | :---------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |
| User Experience | Opens the app directly. If the app is missing, it opens the web URL.                                                    | If the app is installed, it opens the app. If the app is missing, the browser often displays an error. |
| Verification    | Links are associated with your domain using the Digital Asset Links file, preventing other apps from intercepting them. | Any app can declare the same scheme (such as `myapp://`), leading to collisions.                       |
| Protocol        | Uses standard web URLs HTTP/HTTPS.                                                                                      | Requires non-standard schemes. For example, `myapp://`.                                                |

## Define the digital asset links

To enable App Links, you must create a JSON file named `assetlinks.json`. This file defines the relationship between your website and your application. Host the file at the following location: `https://yourdomain.com/.well-known/assetlinks.json`.

Ensure your server meets the configuration requirements:

* The file must be served over HTTPS.
* The file must be served with the `Content-Type` header set to `application/json`.

The following example demonstrates how to configure your package namespace and signing fingerprint.

```json
[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.yourcompany.yourapp",
      "sha256_cert_fingerprints": [
        "4A:34:B4:72:DE:F7:..."
      ]
    }
  }
]
```

**Obtaining the SHA-256 Fingerprint**<br />You can retrieve your signing key fingerprint using the `keytool` command line utility. Alternatively, in Android Studio, navigate to the **Gradle** tab and run the **signingReport** task.

### Configuration reference

The following table describes the keys used to configure the `assetlinks.json` file.

| Key                        | Description                                                                                                 |
| :------------------------- | :---------------------------------------------------------------------------------------------------------- |
| `relation`                 | A list of permissions being granted. Use `delegate_permission/common.handle_all_urls` to handle deep links. |
| `namespace`                | The namespace of your application. Usually `android_app`.                                                   |
| `package_name`             | The unique application ID defined in your `build.gradle` file.                                              |
| `sha256_cert_fingerprints` | The SHA-256 fingerprint of your app's signing certificate.                                                  |

## Verify your configuration

Run the following command in your terminal to confirm your server is returning the correct Content-Type (it must be `application/json`):

```bash
curl -I https://yourdomain.com/.well-known/assetlinks.json
```

The response headers should include `Content-Type: application/json`.

## Configure the manifest

To handle the links, you must configure an intent filter in your `AndroidManifest.xml` file. This tells the Android system which URLs your app can handle.

Add the `autoVerify="true"` attribute to the intent filter. This instructs Android to verify the domain ownership by checking the `assetlinks.json` file upon installation. For example:

```xml
<activity
    android:name=".MainActivity"
    android:exported="true"> 
    
    <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" />
        <data android:host="your-domain.com" />
        <data android:pathPrefix="/products" />
        <data android:pathPattern="/profile" />
    </intent-filter>
    
</activity>
```

## Handle incoming links

Android delivers the App Link to your Activity using an `Intent`. You must check for this `Intent` in both `onCreate` (for when the app starts) and `onNewIntent` (for when the app is already running).

The following example demonstrates how to extract the data from the Intent and route the user to the correct content.

```kotlin
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Check the initial Intent when the app launches
        handleIntent(intent)
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        // Check the Intent if the Activity is already running
        handleIntent(intent)
        setIntent(intent) 
    }

    private fun handleIntent(intent: Intent?) {
        if (intent?.action == Intent.ACTION_VIEW) {
            intent.data?.let { uri ->
                handleDeepLink(uri)
            }
        }
    }

    private fun handleDeepLink(appUri: Uri) {
        println("Incoming App Link URI: $appUri")

        // 1. Extract path and parameters
        val path = appUri.path 
        
        // 2. Route the user to the correct content
        if (path?.startsWith("/products") == true) {
            val productId = appUri.getQueryParameter("id") 
            
            if (productId != null) {
                navigateToProductDetail(productId) 
            }
        } else if (path == "/profile") {
            navigateToProfile()
        } 
    }

    // Example navigation functions
    private fun navigateToProductDetail(id: String) {
        println("Navigating to product view for ID: $id")
    }

    private fun navigateToProfile() {
        println("Navigating to Profile View")
    }
}
```

## Configure your deep link strategy (optional)

Android App Links function without a fallback. However, Trustly recommends having a default deep link strategy configured for your merchant account. This ensures your application has a consistent fallback behavior if a strategy isn't explicitly provided within the `establishData` object in your code.

Any settings passed within the `establishData` object in your code override the default configurations stored in your Trustly account profile.

Because this setup requires internal configuration, you'll need to contact your Customer Success Manager (CSM) or <a href="mailto:us.support@trustly.com">Trustly Support</a> to enable this fallback for your account.

When you submit your request, you must provide the following information:

* **Deep link strategy**: Specify `universal-link`. Trustly uses this unified backend term for both iOS Universal Links and Android App Links.
* **Universal Link**: Provide your fully qualified domain (for example, `https://yourdomain.com/`).