Getting Started
React Native API Integration
Last updated
Was this helpful?
Was this helpful?
npm install airbridge-react-native-sdkyarn add airbridge-react-native-sdk<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Replace YOUR_SCHEME with your actual app scheme -->
<data android:scheme="YOUR_SCHEME" />
</intent-filter><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" />
<!-- Replace YOUR_APP_NAME with your actual app name -->
<data android:scheme="https" android:host="YOUR_APP_NAME.abr.ge" />
</intent-filter>
<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" />
<!-- Replace YOUR_APP_NAME with your actual app name -->
<data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
</intent-filter>import co.ab180.airbridge.reactnative.AirbridgeReactNative
override fun onCreate() {
super.onCreate()
// Replace YOUR_APP_NAME and YOUR_APP_SDK_TOKEN with your actual values
AirbridgeReactNative.initializeSDK(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN")
}import android.content.Intent
import android.os.Bundle
import co.ab180.airbridge.reactnative.AirbridgeReactNative
override fun onResume() {
super.onResume()
AirbridgeReactNative.trackDeeplink(intent)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
}applinks:YOUR_APP_NAME.airbridge.io
applinks:YOUR_APP_NAME.abr.geimport AirbridgeReactNative
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Replace YOUR_APP_NAME and YOUR_APP_SDK_TOKEN with your actual values
AirbridgeReactNative.initializeSDK(name: "YOUR_APP_NAME", token:"YOUR_APP_SDK_TOKEN")
return true
}// Scheme deeplink
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
AirbridgeReactNative.trackDeeplink(url: url)
return true
}
// Universal links
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
AirbridgeReactNative.trackDeeplink(userActivity: userActivity)
return true
}import React, { useEffect, useState } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { Airbridge } from 'airbridge-react-native-sdk';
import queryString from 'query-string';
function App() {
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
Airbridge.setOnDeeplinkReceived((url) => {
// Parse URL params for visitor_id and referrer.
const parsed = queryString.parseUrl(url);
const visitorId = parsed.query.visitor_id;
const referrer = parsed.query.referrer;
// Save in AsyncStorage for later usage during signup
});
checkLoginStatus();
}, []);
const checkLoginStatus = async () => {
try {
const token = await AsyncStorage.getItem("loggedIn");
// your login logic
} catch (error) {
console.log(error);
} finally {
setIsLoading(false);
}
};
if (isLoading) return null;
return (
// your navigation container or main view
);
}
export default App;final referralParams = {
'email': 'user@example.com', // Capture this from user
'hosting_url': 'https://a.domain.co/', // Optional value, and set as default by admin
'name': 'User Name', // Capture this from user
'referrer': 'referrerCode', // Optional value, Get from the deep link as referral_code. only necessary if you want to capture the referrer code from user
'uuid': 'MF*******', // Get this from RH Dashboard
'device': getDeviceType(), // Get device type
'os_type': getOperatingSystem(), // Get operating system type
'visitor_id': sub_********, // Get this from the deep link params
'status': 'custom_event_pending' //Use 'custom_event_pending' to set the referral status to pending
};