Migrating from Branch to Airbridge in React Native
This guide will help you remove Branch integration and add Airbridge SDK to your React Native app.
1. Remove Branch Integration
1.1 Remove Package
Uninstall the Branch dependency:
npm uninstall react-native-branch
1.2 iOS Changes
a) Remove Associated Domains
Navigate to: Xcode → Target → Signing & Capabilities → Associated Domains
Remove all
applinks:
entries like:applinks:your-subdomain-1.app.link applinks:your-subdomain-2-alternate.app.link
b) Remove Info.plist Configurations
Delete the following keys from Info.plist
:
branch_universal_link_domains
branch_key
c) Remove Branch Code from AppDelegate
Remove these from AppDelegate.swift
:
import RNBranch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
RNBranch.initSession(launchOptions: launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
RNBranch.application(app, open:url, options:options)
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
RNBranch.continue(userActivity)
return true
}
1.3 Android Changes
a) Remove Branch Config from AndroidManifest.xml
Remove the following from <application>
:
<!-- Branch SDK Key -->
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_XXX" />
<!-- Branch Universal Link Domains -->
<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" />
<data android:scheme="https" android:host="example.app.link" />
<data android:scheme="https" android:host="example-alternate.app.link" />
</intent-filter>
b) Remove Branch from MainActivity.kt
import io.branch.rnbranch.*
import android.content.Intent
override fun onStart() {
super.onStart()
RNBranchModule.initSession(getIntent().getData(), this)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
RNBranchModule.reInitSession(this)
}
c) Remove Branch from MainApplication.kt
import io.branch.rnbranch.*
override fun onCreate() {
super.onCreate()
RNBranchModule.getAutoInstance(this)
// Remove Branch logging code if added
}
d) Remove Branch Subscription Code
From your root component:
import branch from 'react-native-branch';
useEffect(() => {
const unsubscribe = branch.subscribe(({ error, params }) => {
if (error) return;
// Branch deep link logic
});
return () => unsubscribe();
}, []);
2. Add AirBridge Integration
In the code below, replace the placeholder variables YOUR_APP_NAME and YOUR_APP_SDK_TOKEN with your actual values.
Integration credentials
If you already have an AirBridge account, keep your credentials ready. If you don’t have them yet, no problem — we’ll handle the setup for you. Once you configure your referral tracking campaign and enable Mobile Apps, we’ll email you the required integration credentials, including:
YOUR_APP_SDK_TOKEN
YOUR_APP_NAME
If you don’t receive the email, please contact ReferralHero Support at support@referralhero.com
2.1 Install Airbridge SDK
Using NPM
npm install airbridge-react-native-sdk
Using yarn
yarn add airbridge-react-native-sdk
2.2 Android Setup
a) Add Intent Filters in AndroidManifest.xml
Add under your <activity>
:
Scheme Deep Link:
<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>
App Links:
<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>
b) Initialize SDK in MainApplication.kt
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")
}
c) Track Deep Links in MainActivity.kt
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)
}
2.3 iOS Setup
a) Associated Domains
To configure:
Open your project in Xcode.
Navigate to Target → Signing & Capabilities.
Add a new Associated Domains entry.
Add an entry in the following format:
applinks:YOUR_APP_NAME.airbridge.io
b) Initialize SDK in AppDelegate file
import 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
}
c) Handle Deep Links
// 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
}
2.4 React Native Deep Link Handling
Place this code in the root file of your project. Fetch the required parameters and store them for later use in the Signup API. The two key parameters are:
visitor_id: The unique ID of the referred visitor who clicked the referral link. This must be included in the Signup API to track and attribute the referral upon signup.
referrer: The identifier of the original referrer. This is optional, as
visitor_id
alone is sufficient for tracking the referral.
import { Airbridge } from 'airbridge-react-native-sdk';
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
});
✅ Migration Complete
You’ve successfully removed Branch and integrated Airbridge.
Last updated