branch-react-native-sdk

0.0.8 • Public • Published

Branch Metrics React Native SDK Reference

This is a repository of our open source React Native SDK. Huge shoutout to our friends at Dispatcher, Inc. for their help in compiling the initial version of this SDK.

Tested with React Native 0.21.0.

Supports iOS and Android.

Limited Functionality!

The React Native SDK currently implements a subset of Branch features. We plan to add further functionality soon, and would gladly accept pull requests!

Wish List:

Installation

The SDK is available as a package on NPM. To get it, use these commands:

npm install rnpm -g
npm install --save branch-react-native-sdk
rnpm link branch-react-native-sdk
cd node_modules/branch-react-native-sdk
pod install #Only required for iOS 

Android

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 ':branch-react-native-sdk', ':app'
 
// The relative path to the branch-react-native-sdk directory tends to often be prefixed with one too many "../"s
project(':branch-react-native-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/branch-react-native-sdk/android')
// file: android/app/build.gradle
...
 
dependencies {
    ...
    compile project(':branch-react-native-sdk')
}

iOS

  1. Navigate into the SDK package directory: cd node_modules/branch-react-native-sdk.
  2. Use CocoaPods to install dependencies: pod install.
  3. Drag /node_modules/react-native-branch/Pods/Pods.xcodeproj into the Libraries folder of your Xcode project.
  4. In Xcode, drag the libBranch.a Product from Pods.xcodeproj into your the Link Binary with Libraries section of Build Phases for your project’s target.

Next Steps

Please see our main SDK Integration Guide for complete setup instructions.

  • Enable Universal & App Links — traditional URI scheme links are no longer supported in many situations on iOS 9.2+, and are a less than ideal solution on new versions of Android. To get full functionality from your Branch links on iOS devices, you should enable Universal Links as soon as possible.
  • Learn how to create Branch links in your app.
  • Set up deep link routing

Additional Resources

Usage

var branch = require('branch-react-native-sdk');
 
//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});
 
var shareOptions = {messageHeader: "Check this out!", messageBody: "Check this cool thing out: "};
var branchUniversalObject = {metadata: {prop1: "test", prop2: "abc"}, canonicalIdentifier: "RNBranchSharedObjectId", contentTitle: "Cool Content!", contentDescription: "Cool Content Description", contentImageUrl: ""};
var linkProperties = {feature: 'share', channel: 'RNApp'};
branch.showShareSheet(shareOptions, branchUniversalObject, linkProperties, ({channel, completed, error}) => {});
 
branch.logout();

Package Sidebar

Install

npm i branch-react-native-sdk

Weekly Downloads

0

Version

0.0.8

License

MIT

Last publish

Collaborators

  • aeromusek
  • maephet