Deep linking
Register a deeplink callback
Section titled “Register a deeplink callback”static void registerDeeplinkCallback(OnDeeplinkCallback callback); // lib/affise.dart:42typedef 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 });}Example
Section titled “Example”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).
Custom scheme
Section titled “Custom scheme”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>Add CFBundleURLTypes to Info.plist:
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string>YOUR_DOMAIN</string> <key>CFBundleURLSchemes</key> <array> <string>YOUR_SCHEME</string> </array> </dict></array>adb shell am start -a android.intent.action.VIEW -d "YOUR_SCHEME://YOUR_DOMAIN/somepath?param=1\&list=some\&list=other\&list="xcrun simctl openurl booted "YOUR_SCHEME://YOUR_DOMAIN/somepath?param=1&list=some&list=other&list=1"AppLinks / Universal Links
Section titled “AppLinks / Universal Links”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).
Host https://yoursite/.well-known/apple-app-site-association on your domain and add the associated-domains capability to Info.plist:
<key>com.apple.developer.associated-domains</key><array> <string>applinks:YOUR_DOMAIN</string></array>Deferred deeplinks
Section titled “Deferred deeplinks”static void getDeferredDeeplink(ReferrerCallback callback); // lib/affise.dart:208static void getDeferredDeeplinkValue(ReferrerKey key, ReferrerCallback callback); // lib/affise.dart:215Both 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.