Skip to main content
The Userpilot Capacitor plugin supports a custom URL scheme that lets you preview experiences on a real device before publishing them, and that carries push notification taps back into your app. Setting it up is two steps: register the scheme on each platform so the OS routes matching links to your app, then forward the incoming URL to the Userpilot SDK from your web layer.

Prerequisites

Your app must be configured to handle deep links on both Android and iOS.

Register the custom URL scheme

Replace APP_TOKEN with your app’s Userpilot token, which you can obtain from your Environments Page. For example, if your token is NX-12345678, your scheme value is userpilot-nx-12345678. For iOS, uri-scheme writes the Info.plist entry for you:
For Android, add the intent filter to android/app/src/main/AndroidManifest.xml on the main Activity. Set android:launchMode="singleTop" so an incoming link is delivered to the running Activity rather than creating a second instance of it:
Keep android:host="sdk" in the filter. The native Userpilot SDK validates the URL host before handling a preview or notification link. Run npx cap sync after editing native configuration.

Handle the custom URL scheme

Listen for the appUrlOpen event from @capacitor/app and pass each URL to Userpilot.didHandleURL.
didHandleURL is asynchronous and resolves to an objectThe signature is didHandleURL({ url }): Promise<{ handled: boolean }>. You must await it and read the handled property. Testing the returned value directly always looks truthy, because an unawaited promise is an object, so your own link handling never runs.
Mount the listener once, near the root of your app, so it’s active before any link arrives:
For more on link handling in Ionic, see the Ionic documentation on deep links.
The SDK only claims a URL when the scheme matches your token and the host is sdk. Every other URL is passed back to your app.
On iOS, notification taps are handled natively by the SDK and never reach the appUrlOpen event, so follow Push Notifications for that setup.

Preview an experience with a QR code

Userpilot can render a draft experience on your device before you publish it, so you can check layout, copy, and behavior on a real screen. Preview is supported for Flows and Surveys. The preview is delivered over the custom URL scheme. It works once your app is installed on the device and the scheme is registered and handled as described above.
1

Open the experience

Open a Flow or Survey in the Experience Builder and enter Edit Mode.
2

Start the preview

Select Preview in the top-right corner of the builder. A popup with a QR code appears.
3

Scan the QR code

Scan the code with your device camera. Your app opens and the experience appears.
Points to keep in mind:
  • You don’t need to apply or save your changes before previewing them.
  • The experience doesn’t need to be live.
  • A preview bypasses the experience’s targeting and frequency settings, so it appears even when the current user wouldn’t normally qualify for it.
  • Once you close the experience, the app resumes normal behavior.

Test push notifications

You can send a test push to a specific user from the Userpilot dashboard and verify delivery and tap handling on a real device without sending anything to your wider audience. The notification doesn’t need to be live, so you can test it while it’s still a draft.
  • Test pushes work in both the staging and production environments.
  • Test pushes are not counted as real sends, and they’re excluded from analytics.
  • Test pushes bypass the notification’s targeting and frequency settings.
For the dashboard steps, see Mobile push notifications. Because a notification tap arrives as a deep link on Android, a test push also exercises your appUrlOpen handling there. If the notification appears but tapping it does nothing, the scheme registration is the first thing to check.
Open a link directly to confirm your scheme is registered and your listener runs, without going through the Builder:
Replace the scheme with your own token and 12345 with a real experience ID.

Troubleshooting

Confirm the registered scheme matches your token exactly, lowercased. Then confirm you ran npx cap sync and rebuilt, since a scheme is native configuration and won’t appear in an older build. Verify with the commands above.
The OS routed the link, so registration is correct. Check that AppUrlListener is mounted at the root of your app rather than inside a page that may not be rendered when the link arrives, and confirm the SDK is initialized with the same token that generated the QR code.
Notification taps travel over this same URL scheme on Android, so they need the intent filter and the appUrlOpen forwarding described above. Confirm the host in your filter is exactly sdk.
Each environment has its own token, and the scheme follows the token. Confirm the staging build registers the scheme for the token it initializes the SDK with.