Skip to main content
The deep links module handles deferred deep links — routing users to the correct screen on first launch after installing from a link. A deferred deep link works across the install boundary:
  1. User clicks a link on the web
  2. User is redirected to the Play Store and installs your app
  3. On first launch, the SDK resolves the original link and returns the destination
AppDNA.deepLinks.checkDeferred { deepLink ->
    deepLink?.let {
        // deepLink.screen = "/workout/123"
        // deepLink.params = mapOf("ref" to "instagram")
        navigate(it.screen, it.params)
    }
}
checkDeferred should be called once on first launch, typically after configure() completes. The SDK uses the Google Install Referrer API to resolve deferred links on Android.

Module Access

val deepLinks = AppDNA.deepLinks

Module Methods

MethodSignatureDescription
checkDeferredcheckDeferred(callback: (DeepLink?) -> Unit)Check for a deferred deep link
handleIncominghandleIncoming(intent: Intent)Pass an incoming deep link intent to the SDK
setDelegatesetDelegate(delegate: DeepLinkDelegate?)Set a delegate for deep link callbacks
PropertyTypeDescription
screenStringTarget screen path
paramsMap<String, String>Additional parameters
sourceString?Attribution source

DeepLinkDelegate

AppDNA.deepLinks.delegate = object : DeepLinkDelegate {
    override fun onLinkReceived(url: String, params: Map<String, String>) {
        route(url, params)
    }

    override fun onDeferredLinkResolved(deepLink: DeepLink) {
        route(deepLink.screen, deepLink.params)
    }
}

Platform Setup

To support App Links on Android:
  1. Add intent filters to your AndroidManifest.xml:
<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" android:host="yourapp.com" />
</intent-filter>
  1. Host a Digital Asset Links file at https://yourapp.com/.well-known/assetlinks.json.

Handling in Activity

Pass incoming intents to the SDK:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    intent?.let { AppDNA.deepLinks.handleIncoming(it) }
}

override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    AppDNA.deepLinks.handleIncoming(intent)
}

Auto-Tracked Events

EventTrigger
deep_link_receivedA deep link is opened
deferred_deep_link_resolvedA deferred deep link is resolved on first launch

Full Example

import ai.appdna.sdk.AppDNA
import ai.appdna.sdk.DeepLinkDelegate
import ai.appdna.sdk.DeepLink

class MainActivity : AppCompatActivity(), DeepLinkDelegate {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        AppDNA.deepLinks.delegate = this

        // Check for deferred deep link on first launch
        AppDNA.deepLinks.checkDeferred { deepLink ->
            if (deepLink != null) {
                route(deepLink.screen, deepLink.params)

                deepLink.source?.let { source ->
                    AppDNA.identify(
                        userId = currentUserId,
                        traits = mapOf("install_source" to source)
                    )
                }
            } else {
                showOnboarding()
            }
        }

        intent?.let { AppDNA.deepLinks.handleIncoming(it) }
    }

    override fun onLinkReceived(url: String, params: Map<String, String>) {
        route(url, params)
    }

    override fun onDeferredLinkResolved(deepLink: DeepLink) {
        route(deepLink.screen, deepLink.params)
    }

    private fun route(screen: String, params: Map<String, String>) {
        // Route to the correct screen
    }
}
Deep link routes are configured in the Console under Engagement > Deep Links.