Skip to content

Deep linking

static void registerDeeplinkCallback(OnDeeplinkCallback callback); // lib/affise.dart:42

typedef OnDeeplinkCallback = void Function(DeeplinkValue value); (lib/deeplink/on_deeplink_callback.dart:3).

DeeplinkValue (lib/deeplink/deeplink_value.dart:1-21):

class DeeplinkValue {
String deeplink;
String? scheme;
String? host;
String? path;
Map<String, List<String>> parameters;
DeeplinkValue({ required this.deeplink, this.scheme, this.host, this.path, required this.parameters });
}
void init() {
Affise.settings(affiseAppId, secretKey).start(); // Start Affise SDK
Affise.registerDeeplinkCallback((value) {
// full uri "scheme://host/path?parameters"
var deeplink = value.deeplink;
// separated for convenience
var scheme = value.scheme;
var host = value.host;
var path = value.path;
var queryParametersMap = value.parameters;
if(queryParametersMap["<your_uri_key>"]?.contains("<your_uri_key_value>") == true) {
// handle value
}
});
}

Under the hood, registerDeeplinkCallback also issues AffiseApiMethod.INITIAL_LINK (lib/native/affise_native.dart:72, 302-304) and the stream handler maps incoming data with DataMapper.toDeeplinkValue (lib/native/affise_native.dart:400-410).

Add an intent filter to your launcher Activity in AndroidManifest.xml:

<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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:host="YOUR_DOMAIN"
android:scheme="YOUR_SCHEME" />
</intent-filter>
Terminal window
adb shell am start -a android.intent.action.VIEW -d "YOUR_SCHEME://YOUR_DOMAIN/somepath?param=1\&list=some\&list=other\&list="

AppLinks/Universal Links use the same Affise.registerDeeplinkCallback API — there is no separate Dart entry point.

Host https://yoursite/.well-known/assetlinks.json on your domain, and declare the matching intent-filter with android:autoVerify="true" (see Custom scheme above).

static void getDeferredDeeplink(ReferrerCallback callback); // lib/affise.dart:208
static void getDeferredDeeplinkValue(ReferrerKey key, ReferrerCallback callback); // lib/affise.dart:215

Both APIs require the Status module to be installed.

Affise.getDeferredDeeplink((deferredDeeplink) {
// handle deferred deeplink
});
Affise.getDeferredDeeplinkValue(ReferrerKey.CLICK_ID, (deferredDeeplinkValue) {
// handle deferred deeplink value
});

Native callbacks are dispatched via AffiseApiMethod.GET_DEFERRED_DEEPLINK_CALLBACK / GET_DEFERRED_DEEPLINK_VALUE_CALLBACK (lib/native/affise_native.dart:134-147, handled at :343-350).

For the full ReferrerKey enumeration, see Referrer.