Search specific term/phrase surrounded by double quotes. e.g. “deep linking”
Exclude records that contain a specific term prefixed with a minus. e.g. Android -Firebase

React Native Basic Integration

Steps for basic integration of the Branch React Native SDK into your React Native app.

1. Configure Branch Dashboard

Start by configuring the Branch Dashboard for your application:

  1. iOS Branch Dashboard Configuration steps.
  2. Android Branch Dashboard Configuration steps.

Make sure to configure your default link settings as part of the setup process.

2. Install Branch

Please choose one of the following integration methods to install the Branch React Native SDK into your app.

Pure React Native App

Use one of the following commands to install the module:

NPM

npm install react-native-branch

Yarn

yarn add react-native-branch

Note: The react-native-branch module requires your react-native version to be greater than or equal to 0.60.

Native iOS App With CocoaPods

  1. Add the following code to your Podfile in order to install Branch using CocoaPods:
platform :ios, '11.0'

target 'APP_NAME' do
  # if swift
  use_frameworks!

  pod 'react-native-branch', path: '../node_modules/react-native-branch'
end
  1. Run the pod install command to regenerate the Pods project with the new dependencies. Please note that the location of node_modules relative to your Podfile may vary.

3. Configure App

Complete the app configuration steps for the relevant platform(s) you are using.

iOS Configuration

To configure iOS:

  1. Configure bundle identifier.
  2. Configure associated domains.
  3. Configure Info.plist file.
  4. Add a branch.json file to your project, which you will use to access certain Branch configuration settings:
    1. Create an empty file called branch.json.
    2. Add the file to your project using Xcode. Within your project, navigate to FileAdd Files.
    3. Select the branch.json file and make sure every target in your project that uses Branch is selected.
    4. Click Add.

Android Configuration

To configure Android:

  1. Add dependencies.
  2. Configure AndroidManifest.xml file.
  3. Add a branch.json file to your project, which you will use to access certain Branch configuration settings.
    1. Create an empty file called branch.json.
    2. Place the file in the src/main/assets folder of your app.

4. Initialize Branch

Use the code samples in this section to initialize the SDK in your application(s).

Branch Initialization on iOS

To initialize Branch on iOS, add the following to your app's AppDelegate file:

Branch Initialization on Android

To initialize Branch on Android, you need to:

  1. Add Branch to your MainApplication.kt file (or MainApplication.java for older apps):
  1. Add Branch to your MainActivity.kt file (or MainActivity.java for older apps):

5. Validate Integration

Use the guides below to validate that your SDK integration(s) are properly configured:

iOS

Android

Common Build Problems

  • Be sure to update from < 2.0.0 if your app used an earlier version of react-native-branch. In version 2.x, the native SDKs are embedded in the NPM module and must not also be added from elsewhere (Gradle, CocoaPods, etc.).
  • Note that when using the React pod in a native app, the name of the native SDK pod is Branch-SDK, not Branch, and it comes from node_modules, not the CocoaPods repo.
  • Starting with React Native 0.40, all external iOS headers in Objective-C must be imported as #import <PackageName/Header.h>. This applies to React Native headers as well as the <react-native-branch/RNBranch.h> header from this SDK.
  • If you upgraded from RN < 0.40 manually, without adjusting your Xcode project settings, you may still be importing headers with double quotes. This probably indicates a problem with your settings.
  • The react-native-git-upgrade tool from NPM may be used to update dependencies as well as project settings.
  • On Android, when using Proguard in release builds, depending on your build settings, it may be necessary to add one or both of these lines to your android/app/proguard-rules.pro file:
    -dontwarn com.crashlytics.android.answers.shim.**
    -dontwarn com.google.firebase.appindexing.**
    

Recommended Next Steps

Once you've validated your SDK integration, try getting started with Branch Events or Branch Deep Links: