The deep links module handles deferred deep links — routing users to the correct screen on first launch after installing from a link.
Deferred Deep Links
A deferred deep link works across the install boundary:
- User clicks a link on the web
- User is redirected to the Play Store and installs your app
- 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
| Method | Signature | Description |
|---|
checkDeferred | checkDeferred(callback: (DeepLink?) -> Unit) | Check for a deferred deep link |
handleIncoming | handleIncoming(intent: Intent) | Pass an incoming deep link intent to the SDK |
setDelegate | setDelegate(delegate: DeepLinkDelegate?) | Set a delegate for deep link callbacks |
DeepLink
| Property | Type | Description |
|---|
screen | String | Target screen path |
params | Map<String, String> | Additional parameters |
source | String? | 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)
}
}
App Links
To support App Links on Android:
- 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>
- 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
| Event | Trigger |
|---|
deep_link_received | A deep link is opened |
deferred_deep_link_resolved | A 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.