This version is maintained to support versions of react-native < 0.60. If you are using react-native >= 0.60, please update to version 4.0 of this SDK.
yarn add react-native-branch
- (Optional) Add a branch.json file to the root of your app project. See https://rnbranch.app.link/branch-json.
react-native link react-native-branch
- Install the native Branch SDK using CocoaPods or Carthage.
- Follow the setup instructions.
Use the following to import the react-native-branch SDK depending on your configuration:
Objective-C (static library, including Swift bridging header):
#import <react-native-branch/RNBranch.h>
Objective-C (framework):
@import react_native_branch;
Swift (framework):
import react_native_branch
Version 4.0 provides one import for each language, independent of other configuration and settings.
If you use react-native link
, no further change is necessary to your app/build.gradle
.
In a native app, import the react-native-branch
project like this:
implementation project(':react-native-branch')
If you're using an older version of Gradle, you may need compile
rather than
implementation
. If you are already using the native Branch SDK in your app,
it will now be imported from Maven via react-native-branch
as a dependency.
Remove any reference to io.branch.sdk.android:library
from your dependencies
to avoid conflicts.
Also add the project to your settings.gradle
:
include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
The location of your node_modules
folder may vary.