Skip to main content

This documentation covers @apliko/react-native-deep-link 0.3.0.

Testing

iOS Testing Script

You can test iOS deep links in the simulator with these commands:

bash
xcrun simctl openurl booted "myapp://example/path"
xcrun simctl openurl booted "https://<your-subdomain>.nvgt.link/path"

An https link may open in Safari instead of your app until iOS has verified your app's Associated Domains. If that happens, check your Platform Setup and reinstall the app.

Android Testing Script

For Android emulators, use these adb commands, replacing com.example with your app's package name:

bash
adb shell am start -W -a android.intent.action.VIEW -d "myapp://example/path" com.example
adb shell am start -W -a android.intent.action.VIEW -d "https://<your-subdomain>.nvgt.link/path" com.example

Use AplikoLinkTesting from @apliko/react-native-deep-link/testing in development builds (they do nothing in release builds). Call both before init(). Top-level await doesn't work in React Native's entry file, so wrap it in a function:

typescript
import { AplikoLink } from '@apliko/react-native-deep-link';
import { AplikoLinkTesting } from '@apliko/react-native-deep-link/testing';

async function startWithMockDeferredLink() {
  await AplikoLinkTesting.simulateFreshInstall();
  AplikoLinkTesting.setMockDeferredLink('https://<your-subdomain>.nvgt.link/abc123');
  AplikoLink.init({ apiKey: 'your-client-api-key', debug: true, enableDeferred: { ios: true } });
}
startWithMockDeferredLink();

The mock respects enableDeferred like a real deferred link and always counts as a fresh install, so it can't test what happens after an app update. The mock also needs the SDK's native module, so it doesn't work in Expo Go or in a build made before installing 0.3.0.

Jest (your app's tests)

The SDK loads its React Native build in your app's Jest tests as long as React Native is installed. If your tests use the jsdom environment, add testEnvironmentOptions: { customExportConditions: ['react-native'] } to your Jest config, because jsdom asks for browser builds otherwise.

Test deferred links on real devices

The test utilities check how your app handles a deferred link. To check the whole journey, from tapping a link to the link arriving after the install, use a store build on a real phone.

Android: Google Play internal testing

Verify on your device. Google doesn't say whether installs from a testing track carry the link to your app. Treat these steps as a guide, and confirm on your own device that the link arrives.

Before you start

  • A project in the Sandbox Hub with your Android app added: its Application ID and the SHA-256 fingerprints of your Play App Signing key and upload key. See your project in the Hub.
  • An Apliko link from that project.
  • A build of your app that uses your cl_test_… key.

Steps

  1. In Play Console, upload the build under Test and release › Testing › Internal testing and roll it out.
  2. On the Testers tab, add your test Google account to an email list, then copy the opt-in link. It appears once the release is available.
  3. On the test phone, signed in to Google Play with that account, open the opt-in link and accept.
  4. Uninstall the app if it is installed.
  5. Open your Apliko link in the phone's browser. Don't paste it into the Google Play app. The link page sends you to Google Play.
  6. Install the app from Google Play and open it. The link arrives in your listener as a deferred link, with its data.
  7. To test again, uninstall the app and repeat from step 5, tapping the link again. Google Play keeps the link from the first tap, so reinstalling without a new tap brings no link.

If no link arrives

  • Check AplikoLink.getDeferredLinkResult().referrer on the first launch after the install, once your listener has had a chance to run. It shows what Google Play passed for this install. If it contains utm_medium=organic or not%20set, Google Play passed no link: repeat steps 4 to 6, and make sure you open the Apliko link in the browser. On later launches it is null. To see what the SDK found, turn on debug: true in init.
  • A build installed any way other than from Google Play, such as an APK copied to the phone or installed with adb, never gets a deferred link.
  • If your own pages send users to Google Play, pass the full Apliko link, URL-encoded: https://play.google.com/store/apps/details?id=com.example.app&referrer=<Apliko link>

iOS: TestFlight or a development build

An App Store or TestFlight install passes nothing to your app, so on iOS a deferred link reaches your app through the Paste button.

Before you start

  • iOS deferred links turned on: enableDeferred: { ios: true }.
  • The paste UI in your app: AplikoPasteHost (or AplikoPasteButton) rendered on the first launch.
  • Your iOS app added to the Sandbox Hub project (Bundle ID and Team ID).
  • A device on iOS 16 or later.

Steps

  1. Delete the app from the device.
  2. In Safari, open your Apliko link and tap the button on the link page. It copies the link and opens the App Store.
  3. Install your build from TestFlight instead (or from a development build from Xcode), and open it straight away. Don't open any other link first.
  4. The paste UI appears. Tap Paste. The link arrives as a deferred link, with its data, and is cleared from the clipboard (unless something else was copied in the meantime).
  5. To test again, delete the app and repeat from step 1.

If the paste UI doesn't appear

  • Check that iOS deferred links are on, that this is the first launch after a fresh install (updating an existing install never offers it), that the app wasn't opened by a link, and that the clipboard still holds the Apliko link.
  • With a development build, open the app soon after building it: an older build installed on a simulator can look like an update.
  • To test your handling without a store install, use simulateFreshInstall() and setMockDeferredLink() (see Testing deferred links).

Debugging

Pass debug: true to init to log what the SDK is doing to the console. Log lines start with [DeepLink DEBUG], [DeepLink WARN] or [DeepLink ERROR], and cover initialization, listeners being added and removed, incoming links, the link details received from Apliko Link, and any errors. Without debug, errors are not logged.

typescript
AplikoLink.init({ apiKey: "your-client-api-key", debug: true });

Troubleshooting

Find the symptom, then check each point. For most issues, turn on debug: true first: the console says what the SDK did and why.

SymptomWhat to check
The link opens the browser instead of the app on iOS
  • Your Associated Domains entry is applinks: plus the host of your project's environment: <sub>.nvgt.link for production, <sub>.sandbox.nvgt.link for sandbox.
  • The Team ID and Bundle ID of your app are set in the Hub. See your project in the Hub.
  • Delete and reinstall the app after changing either.
The link opens the browser instead of the app on Android
  • The Hub has the SHA-256 fingerprint of every key that signs your app, including the Play App Signing key for installs from Google Play. See your project in the Hub.
  • The intent filter's android:host matches your project's host, and the filter has android:autoVerify="true".
  • Reinstall the app, then run adb shell pm get-app-links <package>: your host should show as verified.
data is always {}
  • You use a client key (cl_test_… or cl_live_…) from the same environment as the link. A server key (sv_…) is refused.
  • The link is on your project's host. Custom schemes and other domains always get {}.
  • The device has a connection. While it is offline, links still arrive, with {}.
  • With debug: true, the [DeepLink WARN] lines say why.
No deferred link on Android
  • The app was installed from Google Play through your Apliko link. A sideloaded build gets no link.
  • It is a fresh install: uninstall the app first.
  • If Google Play doesn't answer in time, the link can arrive on a later launch.
  • If the store updated the app before its first launch, no deferred link is delivered.
  • To test without the store, use AplikoLinkTesting (see Testing deferred links).
A deferred link arrives againClearing app data makes the next launch look like a fresh install, so a deferred link can be delivered once more. Reinstall instead when you test.
The iOS Paste button doesn't show
  • The device runs iOS 16 or later.
  • enableDeferred: { ios: true } is set in init.
  • It is the first launch of a fresh install, and the app wasn't opened by a link.
  • A link is on the clipboard: the user tapped the button on your Apliko link's page before installing.
  • AplikoPasteHost (or AplikoPasteButton) is rendered on that first launch. See iOS Paste button.
A link is handled twice, or the app navigates twiceThe link that opened the app and a deferred link go to one listener only. Handle them in one central listener at startup (or AplikoLinkProvider at the root). If a screen listener also navigates on links, act in one of them only. The same link opened twice is delivered twice.
The link that opened the app never arrivesIt is delivered only once, to the first listener or the first getInitialUrl() call. Make sure another listener isn't receiving it first, and use getInitialUrlAsync() instead of calling getInitialUrl() right after init, which returns null until startup has finished. Screens that mount later can read getCurrentLink().
Please call init() first is thrownAplikoLink.init must run before any hook, provider or other SDK call. Call it at the top of your entry file.
Deferred links or the Paste button are missing in Expo Go, or in a build made before installing 0.3.0These need the SDK's native module. Rebuild the app (pod install and a new native build, or a new Expo / EAS development build). Expo Go doesn't include the module. With debug: true the SDK logs when a rebuild is needed.
Android build fails after upgrading to 0.3.00.3.0 adds a native module, so make a new native build after upgrading. If the app was built with a 0.3.0 pre-release, or autolinking looks stale, do a clean Android rebuild: delete android/build and android/app/build, or run ./gradlew clean.
Links are ignored while the app is open on AndroidAdd android:launchMode="singleTask" to your MainActivity.