> 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 full documentation content, see https://amer.developers.trustly.com/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://amer.developers.trustly.com/_mcp/server.

# Migrate from custom schemes (Android)

If your application currently uses custom URL schemes such as `myapp://`, Trustly recommends migrating to [Android App Links](https://developer.android.com/training/app-links). App Links are more secure and provide a better user experience because they are verified against your website, and they prevent other apps from hijacking your links.

To ensure a smooth transition, you should treat the migration as an extension process. Maintain support for the custom scheme to support older app versions while adding App Links as the primary method for modern users.

### Update the manifest

To support both link types simultaneously, you must keep your existing `<intent-filter>` for the custom scheme and add a new one for App Links. The following is the recommended methodology:

* **Keep the existing filter**: This ensures users on older versions of your app, or links hardcoded in emails using `myapp://`, continue to work.
* **Add the App Link filter**: This enables the modern HTTPS handling.

Open your `AndroidManifest.xml` file and add the following entry:

```xml
<activity android:name=".MainActivity">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="myapp" />
    </intent-filter>

    <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" />
    </intent-filter>

</activity>
```

### Create a unified router

To ensure a successful migration, your handling logic must process the `Uri` in a scheme-agnostic way. Since Android delivers the complete `Uri` object to your Activity regardless of the source, you can create a single function to route the user.

The following example demonstrates how to handle both `https` and `myapp` schemes using the same logic.

```kotlin
private fun handleDeepLink(appUri: Uri) {
    println("Incoming URI: $appUri")

    // Inspect the scheme to determine the source
    if (appUri.scheme == "https") {
        println("Detected App Link (Modern)")
    } else if (appUri.scheme == "myapp") {
        println("Detected Deep Link (Legacy)")
    }

    // Extract the path and query parameters using standard Uri functions.
    // This logic works identically for both schemes.
    val path = appUri.path
    
    if (path?.startsWith("/products") == true) {
        val productId = appUri.getQueryParameter("id")
        if (productId != null) {
            navigateToProductDetail(productId)
        }
    }
}
```

By using standard `Uri` functions to get the path and parameters, you simplify maintenance. When the App Link is verified, it automatically takes precedence over the custom scheme without requiring you to rewrite your internal navigation logic.