
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-native-branch
Advanced tools
Native Wrapper around Branch Metrics native SDKs. Tested with React Native 0.21.0.
Supports iOS and Android.
var branch = require('react-native-branch');
//Receives the initSession's result as soon as it becomes available
branch.getInitSessionResultPatiently(({params, error}) => { });
branch.setDebug();
branch.getLatestReferringParams((params) => { });
branch.getFirstReferringParams((params) => { });
branch.setIdentity("Your User's ID");
branch.userCompletedAction("Purchased Item", {item: 123});
branch.logout();
npm install rnpm -g
npm install --save react-native-branch
rnpm link react-native-branch
cd node_modules/react-native-branch
pod install #Only required for iOS
Sometimes rnpm link creates incorrect relative paths, leading to compilation errors
Ensure that the following files look as described and all linked paths are correct
// file: android/settings.gradle
...
include ':react-native-branch', ':app'
// The relative path to the react-native-branch directory tends to often be prefixed with one too many "../"s
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
// file: android/app/build.gradle
...
dependencies {
...
compile project(':react-native-branch')
}
// file: android/app/src/main/java/com/xxx/MainActivity.java
import android.content.Intent; // <-- import
import com.dispatcher.rnbranch.*; // <-- import
public class MainActivity extends ReactActivity {
// ...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNBranchPackage() // <-- add this line, if not already there
);
}
// Add onStart
@Override
public void onStart() {
super.onStart();
RNBranchModule.initSession(this.getIntent().getData(), this);
}
// Add onNewIntent
@Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
// ...
}
Please follow [these instructions] (https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/#configure-manifest)
Please follow these instructions
Note: The "receiver" element needs to be added to the "application" node in AndroidManifest.xml
Please follow these instructions
Notes:
Please follow these instructions
Note: Just add the "android:name" attribute to your "application" node in your AndroidManifest.xml
Please follow these instructions
Import RNBranch.h at the top
#import "RNBranch.h"
Initialize the Branch Session in didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
NSURL *jsCodeLocation;
///
}
Add the openURL and continueUserActivity functions
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if (![RNBranch handleDeepLink:url]) {
// do other deep link routing for the Facebook SDK, Pinterest SDK, etc
}
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
return [RNBranch continueUserActivity:userActivity];
}
Add a String entry branch_key with your branch key to your plist (as described here)
Please follow these instructions here
Please follow these instructions here
FAQs
Branch Metrics React Native SDK
The npm package react-native-branch receives a total of 54,102 weekly downloads. As such, react-native-branch popularity was classified as popular.
We found that react-native-branch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.