Deep linking
Register a deeplink callback
Section titled “Register a deeplink callback”The public entry point is Affise.registerDeeplinkCallback(callback: OnDeeplinkCallback) (src/index.ts:70-72).
export type OnDeeplinkCallback = (value: DeeplinkValue) => void;// src/deeplink/OnDeeplinkCallback.ts:3The DeeplinkValue class (src/deeplink/DeeplinkValue.ts:1-26) exposes:
deeplink: stringscheme?: stringhost?: stringpath?: stringparameters: 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 }});Custom-scheme deeplinks
Section titled “Custom-scheme deeplinks”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>Declare the URL scheme in Info.plist:
<key>CFBundleURLTypes</key><array> <dict> <key>CFBundleURLName</key> <string>com.yourapp</string> <key>CFBundleURLSchemes</key> <array> <string>yourscheme</string> </array> </dict></array>App Links / Universal Links
Section titled “App Links / Universal Links”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-associationfor iOS support / And has ability to add filehttps://yoursite/.well-known/assetlinks.jsonfor 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.
Enable the Associated Domains capability and list your domain:
<key>com.apple.developer.associated-domains</key><array> <string>applinks:yoursite</string></array>Host apple-app-site-association at https://yoursite/.well-known/apple-app-site-association.
Deferred deeplinks
Section titled “Deferred deeplinks”getDeferredDeeplink
Section titled “getDeferredDeeplink”Affise.getDeferredDeeplink(callback: ReferrerCallback)// src/index.ts:183-185ReferrerCallback = (value: string) => void (src/referrer/ReferrerCallback.ts:1). Maps to AffiseApiMethod.GET_DEFERRED_DEEPLINK_CALLBACK = "get_deferred_deeplink_callback" (src/native/AffiseApiMethod.ts:31).
getDeferredDeeplinkValue
Section titled “getDeferredDeeplinkValue”Affise.getDeferredDeeplinkValue(key: ReferrerKey, callback: ReferrerCallback)// src/index.ts:190-192Maps 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.