Skip to content

Deep linking

The Affise SDK exposes a single callback API — Affise.registerDeeplinkCallback — for both custom-scheme deeplinks and HTTPS AppLinks.

  • Affise.registerDeeplinkCallback(callback: OnDeeplinkCallback) (attribution/src/main/java/com/affise/attribution/Affise.kt:71-74)
  • fun interface OnDeeplinkCallback { fun handleDeeplink(value: DeeplinkValue) } (attribution/src/main/java/com/affise/attribution/deeplink/OnDeeplinkCallback.kt:7-12)
  • data class DeeplinkValue(deeplink: String, scheme: String?, host: String?, path: String?, parameters: Map<String, List<String>>) (attribution/src/main/java/com/affise/attribution/deeplink/DeeplinkValue.kt:5-11)

Declare an intent filter with your custom scheme in AndroidManifest.xml, then register the callback during or after SDK initialization.

Affise.settings(affiseAppId, secretKey).start(context) // Start Affise SDK
Affise.registerDeeplinkCallback { value ->
// full uri "scheme://host/path?parameters"
val deeplink = value.deeplink
// separated for convenience
val scheme = value.scheme
val host = value.host
val path = value.path
val queryParametersMap = value.parameters
if(queryParametersMap["<your_uri_key>"].contains("<your_uri_key_value>")) {
// handle value
}
}

| Field | Type | |---|---| | deeplink | String | | scheme | String? | | host | String? | | path | String? | | parameters | Map<String, List<String>> |

The SDK uses the same Affise.registerDeeplinkCallback(...) API for HTTPS AppLinks. Unlike custom-scheme deeplinks, AppLinks require:

  • an intent filter with http/https scheme and android:autoVerify="true"
  • an assetlinks.json served at https://yoursite/.well-known/assetlinks.json

Requires the Status module.

  • Affise.getDeferredDeeplink(callback: OnReferrerCallback?) (Affise.kt:186-189)
  • fun interface OnReferrerCallback { fun handleReferrer(value: String?) } (attribution/src/main/java/com/affise/attribution/referrer/OnReferrerCallback.kt:7-12)
Affise.getDeferredDeeplink { deferredDeeplink ->
// handle deferred deeplink
}

Affise.getDeferredDeeplinkValue(key: ReferrerKey, callback: OnReferrerCallback?) (Affise.kt:194-197). Requires the Status module. For the full list of ReferrerKey values see Referrer.

Affise.getDeferredDeeplinkValue(ReferrerKey.CLICK_ID) { deferredDeeplinkValue ->
// handle deferred deeplink value
}

You can trigger deeplinks from a terminal using adb:

Terminal window
adb shell am start -a android.intent.action.VIEW -d "scheme://host/path?key=value" <your.package.name>