Handle deferred deep links
Deferred deep linking applies when the user does not have your app installed. They open an Adtrace tracker URL with a deep_link, install the app from the store, then open it. Android does not deliver that deep link natively. The Adtrace SDK provides the deep link content after install.
By default, the Adtrace SDK opens deferred deep links automatically. Set a deep link callback on your AdTraceConfig instance if you want to control whether the SDK opens the link.
This page covers the deferred deep link callback on AdTraceConfig. For scheme, manifest, and tracker URL setup, see Set up standard deep linking and the Deep linking overview.
Deep link callback
Method signature
public void setOnDeeplinkResponseListener(OnDeeplinkResponseListener listener)
| Parameter | Type | Description |
|---|---|---|
listener | OnDeeplinkResponseListener | Called when the SDK receives a deferred deep link. Return true to let the SDK open it, or false to handle it yourself. |
Set this callback before AdTrace.onCreate() to decide what happens when the SDK receives a deferred deep link.
| Return value | Behavior |
|---|---|
true | Let the Adtrace SDK open the deep link. |
false | Do not open it. Handle the URL yourself if needed. |
If you do not set this callback, the SDK opens the deep link by default.
Example
Evaluate the deep link in the callback, then return whether the SDK should launch it:
- Java
- Kotlin
AdTraceConfig config = new AdTraceConfig(this, appToken, environment);
config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() {
@Override
public boolean launchReceivedDeeplink(Uri deeplink) {
return shouldAdTraceSdkLaunchTheDeeplink(deeplink);
}
});
AdTrace.onCreate(config);
val config = AdTraceConfig(this, appToken, environment)
config.setOnDeeplinkResponseListener(OnDeeplinkResponseListener { deeplink ->
shouldAdTraceSdkLaunchTheDeeplink(deeplink)
})
AdTrace.onCreate(config)
Replace shouldAdTraceSdkLaunchTheDeeplink(deeplink) with your own logic (for example check the path or query and decide whether the SDK should open the URL).
Example: never open automatically
Return false to prevent the SDK from launching the deep link:
- Java
- Kotlin
config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() {
@Override
public boolean launchReceivedDeeplink(Uri deeplink) {
return false;
}
});
config.setOnDeeplinkResponseListener(OnDeeplinkResponseListener { false })