Skip to content

Deep linking

The public entry point is Affise.registerDeeplinkCallback(callback: OnDeeplinkCallback) (src/index.ts:70-72).

export type OnDeeplinkCallback = (value: DeeplinkValue) => void;
// src/deeplink/OnDeeplinkCallback.ts:3

The DeeplinkValue class (src/deeplink/DeeplinkValue.ts:1-26) exposes:

  • deeplink: string
  • scheme?: string
  • host?: string
  • path?: string
  • parameters: Record<string, string[]>

Internally NativeBasePlatform.reactHandleDeeplink() listens on Linking.getInitialURL() and Linking.addEventListener('url', ...) and forwards URLs to the native nativeHandleDeeplink method (src/native/NativeBasePlatform.ts:56-67).

Affise.registerDeeplinkCallback((value) => {
// full uri "scheme://host/path?parameters"
const deeplink = value.deeplink;
// separated for convenience
const scheme = value.scheme;
const host = value.host;
const path = value.path;
const queryParametersMap = value.parameters;
if((queryParametersMap["<your_uri_key>"] || []).includes("<your_uri_key_value>")) {
// handle value
}
});

Register an intent filter on the activity that should handle incoming URLs. The React Native Linking module will forward the URL and Affise will pick it up through its internal listener.

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="yourscheme" android:host="yourhost" />
</intent-filter>

From. There is no dedicated TypeScript API; rely on the standard platform mechanisms and the regular registerDeeplinkCallback dispatch.

Prerequisite:

You must owne website domain. And has ability to add file https://yoursite/.well-known/apple-app-site-association for iOS support / And has ability to add file https://yoursite/.well-known/assetlinks.json for Android support

Add an auto-verified intent filter for your domain:

<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="yoursite" />
</intent-filter>

Host assetlinks.json at https://yoursite/.well-known/assetlinks.json.

Affise.getDeferredDeeplink(callback: ReferrerCallback)
// src/index.ts:183-185

ReferrerCallback = (value: string) => void (src/referrer/ReferrerCallback.ts:1). Maps to AffiseApiMethod.GET_DEFERRED_DEEPLINK_CALLBACK = "get_deferred_deeplink_callback" (src/native/AffiseApiMethod.ts:31).

Affise.getDeferredDeeplinkValue(key: ReferrerKey, callback: ReferrerCallback)
// src/index.ts:190-192

Maps to AffiseApiMethod.GET_DEFERRED_DEEPLINK_VALUE_CALLBACK = "get_deferred_deeplink_value_callback" (src/native/AffiseApiMethod.ts:32).

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

See referrer for the full ReferrerKey enum.