Deep Link with React Native App
While create the session ID, define the URL
We are going to support the URL (deep links) into the app:
pave://
You can create your custom URL, but make sure you config the same URL in native app. For example, we using the URL is pave://
Create New Session ID
POST
https://openapi.paveapi.com/v1/sessions:api-key
Headers
Name | Type | Description |
---|---|---|
Accept* | String | application/json |
Content-type* | String | application/json |
API-Timestamp* | String | UTC Datetime |
API-Token* | String | Your Generated Access Token |
API-Key* | String | Your API Key |
Sample Request
Please, read the Create Session's document for more information.
Setting up for iOS
Adding a URL scheme
Open up your project and go to Targets > Info > URL Types and add the following:
Change com.discoveryloft.pavejs
to your project's identifier
Update AppDelegate.m
You'll need to add the following lines to your *AppDelegate.m
:
If you're targeting iOS 8.x or older, you can use the following code instead:
Setting up for Android
Add intent filters for incoming links
To create a link to your app content, add an intent filter that contains these elements and attribute values in your manifest:
According to Google, the autoVerify attribute “allows your app to designate itself as the default handler of a given type of link. So when the user clicks on an Android App Link, your app opens immediately if it's installed — the disambiguation dialog doesn't appear.”
Handle URLs
There are two ways to handle URLs that open your app.
1. If the app is already open, the app is foregrounded and a Linking 'url' event is fired
You can handle these events with Linking.addEventListener('url', callback)
- it calls callback({ url })
with the linked URL
2. If the app is not already open, it is opened and the url is passed in as the initialURL
You can handle these events with Linking.getInitialURL()
- it returns a Promise that resolves to the URL, if there is one.
Example
Result
After PAVE Capture successfully and tap on CLOSE
button, you will redirect to your app.
Test
iOS
You can try deeplinking into your app by firing up Safari in your simulator and enter URL in there (i.e. pave://
).
Or an even better way is to execute deeplinks from the command line while your simulator is running with this command here:
xcrun simctl openurl booted pave://
Android
Execute deeplinks from the command line while your simulator is running with this command here:
adb shell am start -a android.intent.action.VIEW -d "pave:\\" <your-app-package-name>
Source code example:
Reference Documents:
Last updated