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:
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:
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.exampleTesting deferred links
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:
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
- In Play Console, upload the build under Test and release › Testing › Internal testing and roll it out.
- 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.
- On the test phone, signed in to Google Play with that account, open the opt-in link and accept.
- Uninstall the app if it is installed.
- 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.
- Install the app from Google Play and open it. The link arrives in your listener as a deferred link, with its data.
- 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().referreron 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 containsutm_medium=organicornot%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 isnull. To see what the SDK found, turn ondebug: trueininit. - 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(orAplikoPasteButton) 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
- Delete the app from the device.
- In Safari, open your Apliko link and tap the button on the link page. It copies the link and opens the App Store.
- 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.
- 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).
- 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()andsetMockDeferredLink()(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.
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.
| Symptom | What to check |
|---|---|
| The link opens the browser instead of the app on iOS |
|
| The link opens the browser instead of the app on Android |
|
data is always {} |
|
| No deferred link on Android |
|
| A deferred link arrives again | Clearing 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 |
|
| A link is handled twice, or the app navigates twice | The 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 arrives | It 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 thrown | AplikoLink.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.0 | These 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.0 | 0.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 Android | Add android:launchMode="singleTask" to your MainActivity. |