The deep links module handles deferred deep links — routing users to the correct screen on first launch after installing from a link.
Deferred Deep Links
const deepLink = await AppDNA.deepLinks.checkDeferred();
if (deepLink) {
// deepLink.screen = "/workout/123"
// deepLink.params = { ref: "instagram" }
navigate(deepLink.screen, deepLink.params);
}
checkDeferred should be called once on first launch, typically after configure() completes. Returns null if no deferred link is found.
Module Access
const deepLinks = AppDNA.deepLinks;
Module Methods
| Method | Signature | Description |
|---|
checkDeferred | checkDeferred(): Promise<DeepLink | null> | Check for a deferred deep link |
handleIncoming | handleIncoming(url: string): void | Pass an incoming deep link to the SDK |
DeepLink
| Property | Type | Description |
|---|
screen | string | Target screen path |
params | Record<string, string> | Additional parameters |
source | string | null | Attribution source |
Event Listeners
const unsubLink = AppDNA.deepLinks.onLinkReceived(
(url: string, params: Record<string, string>) => {
route(url, params);
}
);
const unsubDeferred = AppDNA.deepLinks.onDeferredLinkResolved(
(deepLink: DeepLink) => {
route(deepLink.screen, deepLink.params);
}
);
// Clean up
unsubLink();
unsubDeferred();
Deep links require platform-specific configuration:
iOS: Enable Associated Domains and add applinks:yourapp.com in Xcode.
Android: Add intent filters to your AndroidManifest.xml:
<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="yourapp.com" />
</intent-filter>
Auto-Tracked Events
| Event | Trigger |
|---|
deep_link_received | A deep link is opened |
deferred_deep_link_resolved | A deferred deep link is resolved on first launch |
Full Example
import { AppDNA, DeepLink } from "@appdna/react-native-sdk";
import React, { useEffect } from "react";
function App() {
useEffect(() => {
handleFirstLaunch();
const unsubLink = AppDNA.deepLinks.onLinkReceived((url, params) => {
route(url, params);
});
return () => unsubLink();
}, []);
async function handleFirstLaunch() {
const deepLink = await AppDNA.deepLinks.checkDeferred();
if (deepLink) {
route(deepLink.screen, deepLink.params);
if (deepLink.source) {
await AppDNA.identify(currentUserId, {
install_source: deepLink.source,
});
}
} else {
showOnboarding();
}
}
function route(screen: string, params: Record<string, string>) {
// Route to the correct screen using your navigation library
}
return <>{/* App content */}</>;
}
Deep link routes are configured in the Console under Engagement > Deep Links.