This is a repository of our open source React Native SDK. The information presented here serves as a reference manual for the SDK. See the table of contents below for a complete list of the content featured in this document.
- External resources
- Getting started
- Installation using react-native link
- Installation in a native iOS app using the React pod
- Updating from an earlier SDK version
- Register for Branch key
- Project setup
- Branch general methods
- Register a subscriber
- Unregister a subscriber
- Adjust cached link TTL
- Retrieve latest deep linking params
- Retrieve the user's first deep linking params
- Setting the user id for tracking influencers
- Logging a user out
- Tracking custom events
- Sending commerce events
- Programmatic deep linking
- Branch Universal Objects
- Instantiate a Branch Universal Object
- Register user actions on an object
- List content on Spotlight
- Configuring link properties
- Configuring control parameters
- Creating a short link referencing the object
- Triggering a share sheet to share a link
- Releasing native resources
- Referral rewards methods
Note that the react-native-branch
module requires react-native
>= 0.40.
yarn add react-native-branch
ornpm install --save 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
- Follow the setup instructions.
Only follow these instructions if you are already using the React pod from node_modules. This is usually done in native apps that integrate React Native components.
- Add the following to your Podfile:
Adjust the path if necessary to indicate the location of your
pod "react-native-branch", path: "../node_modules/react-native-branch" pod "Branch-SDK", path: "../node_modules/react-native-branch/ios"
node_modules
subdirectory. - Run
pod install
to regenerate the Pods project with these new dependencies. - (Optional) Add a branch.json file to the your app project. See https://rnbranch.app.link/branch-json.
- Follow the setup instructions.
As of version 2.0.0, the native Branch SDKs are included in the module and must not be installed
from elsewhere (CocoaPods, Carthage or manually). When updating from an earlier
versions of react-native-branch
, you must remove the Branch SDK that was
previously taken from elsewhere.
Open the android/app/build.gradle
file
in your project. Remove:
compile 'io.branch.sdk.android:library:2.+'
And add this line if not already present:
compile fileTree(dir: 'libs', include: ['*.jar'])
The result should be something like
dependencies {
compile project(':react-native-branch')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
Remove the external Branch SDK from your project depending on how you originally integrated it.
Remove "Branch" from your Podfile. Run pod install
after updating the Podfile. This is
necessary to regenerate the Pods project without the Branch pod.
If you added CocoaPods to your project just for the Branch pod, you can remove CocoaPods entirely from your app using the pod deintegrate command.
Replace pod "Branch"
in your Podfile with pod "Branch-SDK", path: "../node_modules/react-native-branch/ios"
.
pod "React", path: "../node_modules/react-native"
# The following line is necessary with use_frameworks! or RN >= 0.42.
pod "Yoga", path: "../node_modules/react-native/ReactCommon/yoga"
pod "react-native-branch", path: "../node_modules/react-native-branch"
pod "Branch-SDK", path: "../node_modules/react-native-branch/ios"
The location of node_modules
relative to your Podfile
may vary.
Run pod install
after making this change.
Remove Branch.framework from your app's dependencies. Also remove Branch.framework from your carthage copy-frameworks
build phase.
Remove Branch.framework from your app's dependencies.
You can sign up for your own app id at https://dashboard.branch.io.
Modify your AppDelegate as follows:
In AppDelegate.m
#import <react-native-branch/RNBranch.h> // at the top
// Initialize the Branch Session at the top of existing application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Uncomment this line to use the test key instead of the live one.
// [RNBranch useTestInstance]
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES]; // <-- add this
NSURL *jsCodeLocation;
//...
}
// Add the openURL and continueUserActivity functions
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if (![RNBranch.branch application:app openURL:url options:options]) {
// do other deep link routing for the Facebook SDK, Pinterest SDK, etc
return YES;
}
return NO;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
return [RNBranch continueUserActivity:userActivity];
}
If you are using react-native link
, your AppDelegate is probably written in Objective-C. When you use
react-native link
, the Branch dependency is added to your project as a static library. If instead
you are using Swift in a pure React Native app with react-native link
, you will require a
bridging header
in order to use any React Native plugin in Swift.
Add #import <react-native-branch/RNBranch.h>
to your Bridging header if you have one.
If you are using the React
pod in a native app with use_frameworks!
, you may simply use
a Swift import:
import react_native_branch
In AppDelegate.swift:
// Initialize the Branch Session at the top of existing application:didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Uncomment this line to use the test key instead of the live one.
// RNBranch.useTestInstance()
RNBranch.initSession(launchOptions: launchOptions, isReferrable: true) // <-- add this
//...
}
// Add the openURL and continueUserActivity functions
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return RNBranch.branch.application(app, open: url, options: options)
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
return RNBranch.continue(userActivity)
}
These instructions are for Swift 3. Please note that Swift 2 is deprecated.
Add RNBranchPackage to packages list in getPackages()
MainApplication.java (android/app/src/[...]/MainApplication.java
).
Note that this is automatically done if you used react-native link
.
Also add a call to Branch.getAutoinstance()
in onCreate()
in the same source file. This has to be
done even if you used react-native link
.
// ...
// import Branch and RNBranch
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
//...
// add RNBranchPackage to react-native package list
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNBranchPackage(), // <-- add this
// ...
// add onCreate() override
@Override
public void onCreate() {
super.onCreate();
Branch.getAutoInstance(this);
}
Override onStart and onNewIntent in MainActivity.java to handle Branch links (android/app/src/[...]/MainActivity.java
).
This has to be done regardless whether you used react-native link
.
import io.branch.rnbranch.*; // <-- add this
import android.content.Intent; // <-- and this
public class MainActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "base";
}
// Override onStart, onNewIntent:
@Override
protected void onStart() {
super.onStart();
RNBranchModule.initSession(getIntent().getData(), this);
}
@Override
public void onNewIntent(Intent intent) {
setIntent(intent);
}
// ...
}
After modifying your AppDelegate:
-
Add a Dictionary or String entry branch_key with your Branch key to your info.plist
-
If using a custom domain in the Branch Dashboard or one or more non-Branch domains, add the
branch_universal_link_domains
key to your Info.plist.
-
Configure AndroidManifest.xml. Be sure to set
android:launchMode="singleTask"
on your main activity. -
Register for Google Play Install Referrer. The "receiver" element needs to be added to the "application" node in AndroidManifest.xml
- The "intent-filter" element needs to be added to the activity node, whose android:name is "com.yourAppName.MainActivity". This node is in the "application" node.
- If you already have an intent-filter tag, this has to be added as an additional one.
- Make sure to replace "yourApp" with the scheme you specified in the Branch dashboard.
-
Enable Auto Session Management. Simply add the "android:name" attribute to your "application" node in your AndroidManifest.xml
-
Enable App Links for Android M and above (optional but recommended)
-
Add your Branch key to AndroidManifest: Inside of application node add
<meta-data android:name="io.branch.sdk.BranchKey" android:value="your_branch_key" />
-
Add the following to your
android/app/proguard-rules.pro
file:
-dontwarn io.branch.**
Please see the Branch SDK Integration Guide for complete setup instructions.
Alternately, you can automatically perform all project configuration setup using Fastlane. See the Branch Fastlane plugin for details.
There are five example apps in this repo. See the examples subdirectory for more details.
To be called back when a link is opened, register a subscriber callback function
using the branch.subscribe
method. Note that unlike the underlying native SDKs,
you do not have to initialize the Branch session from JavaScript. This is done
in native code at app launch, before the JavaScript initializes. If the app was
opened from a link, the initial link is cached by the native layer and returned
to the JavaScript subscriber afterward. This method may be called repeatedly in
different app components. To route links in a pure React Native app, call this
method in componentDidMount
in a component that is mounted at app launch.
In a native app that includes a React Native component, link routing will usually
be done at the native level. This method may still be called from
JavaScript for purposes other than link routing (e.g. custom analytics). Other
Branch SDK methods may be called in this case without calling branch.subscribe
at all in JavaScript.
The callback function you supply to the branch.subscribe
method is called
whenever a link is opened and at certain other times, such as successful SDK
initialization without a deferred deep link.
branch.subscribe(listener)
listener: A function taking an object argument with the shape { error, params }
.
The error
argument is a string. The params
argument is an object. See
Params object for details on the contents.
The return value of branch.subscribe
is a function that cancels the subscription
when called.
import branch from 'react-native-branch'
branch.subscribe(({ error, params }) => {
if (error) {
console.error('Error from Branch: ' + error)
return
}
// params will never be null if error is null
if (params['+non_branch_link']) {
const nonBranchUrl = params['+non_branch_link']
// Route non-Branch URL if appropriate.
return
}
if (!params['+clicked_branch_link']) {
// Indicates initialization success and some other conditions.
// No link was opened.
return
}
// A Branch link was opened.
// Route link based on data in params.
})
The return value of branch.subscribe
is a function that cancels the
subscription when called. Call this in componentWillUnmount
.
import branch from 'react-native-branch'
class MyApp extends Component {
_unsubscribeFromBranch = null
componentDidMount() {
_unsubscribeFromBranch = branch.subscribe({ error, params } => {
// ...
})
}
componentWillUnmount() {
if (_unsubscribeFromBranch) {
_unsubscribeFromBranch()
_unsubscribeFromBranch = null
}
}
}
Any initial link cached by the native layer will be returned to the callback
supplied to branch.subscribe
immediately if the JavaScript method is called
within a certain time from app launch. This allows components to unsubscribe and
resubscribe without receiving the initial link after resubscription. By default,
the TTL for any initial link is 5000 ms. To use a different value, set
branch.initSessionTtl
to that value, in ms. To have the desired effect, this
parameter should be set at app launch.
branch.initSessionTtl
An integer specifying the maximum amount of time, in milliseconds, to cache the initial link from app launch. Defaults to 5000.
import branch from 'react-native-branch'
branch.initSessionTTL = 10000
branch.subscribe({ error, params } => {
// ...
})
These session parameters will be available at any point later on with this command. If no parameters are available then Branch will return an empty dictionary. This refreshes with every new session (app installs AND app opens).
branch.getLatestReferringParams()
A promise. On resolution, the promise returns an object containing the parameters from the latest link open or install. See Params object for details on the contents.
import branch from 'react-native-branch'
const latestParams = await branch.getLatestReferringParams()
If you ever want to access the original session params (the parameters passed in for the first install event only), you can use this line. This is useful if you only want to reward users who newly installed the app from a referral link. Note that these parameters can be updated when setIdentity:
is called and identity merging occurs.
branch.getFirstReferringParams()
A promise. On resolution, the promise returns an object containing the referring parameters from the initial app installation. See Params object for details on the contents.
import branch from 'react-native-branch'
const latestParams = await branch.getFirstReferringParams()
Often, you might have your own user IDs, or want referral and event data to persist across platforms or uninstall/reinstall. It's helpful if you know your users access your service from different devices. This where we introduce the concept of an 'identity'.
branch.setIdentity(userIdentity)
userIdentity: A string specifying the user identity to use.
import branch from 'react-native-branch'
branch.setIdentity('theUserId')
If you provide a logout function in your app, be sure to clear the user when the logout completes. This will ensure that all the stored parameters get cleared and all events are properly attributed to the right identity.
Warning: This call will clear the promo credits and attribution on the device.
branch.logout()
import branch from 'react-native-branch'
branch.logout()
The branch.userCompletedAction
method may be used for custom events that do not
involve specific content views in the app. To record custom events related to
content views, use the userCompletedAction
method on the Branch Universal Object.
branch.userCompletedAction(event, params)
event: A string specifying a custom event name
params: (optional) An object containing custom key-value pairs to associate with the event
import branch from 'react-native-branch'
branch.userCompletedAction('Level Complete', {level: 'Level 1'})
Use the branch.sendCommerceEvent
method to record commerce events.
branch.sendCommerceEvent(revenue, metadata)
revenue: A decimal number represented as a string or a float, e.g. "20.00" or 20.00
metadata: (Optional) Metadata to associate with this event. Keys must be strings.
import branch from 'react-native-branch'
branch.sendCommerceEvent("20.00")
branch.sendCommerceEvent(50, {key1: "value1", key2: "value2"})
The Branch SDK automatically triggers the branch.subscribe
callback whenever a
link is received in the app via App Links, Universal Links or custom URI schemes.
There may be other cases where you want to trigger a link open programmatically,
e.g. from a push notification or a QR reader. Use the branch.openURL
method
to trigger an open of a Branch link from anywhere in your app. In the case of
native apps integrating an RN component, this will also trigger the native
deep link handler callback.
Note: This method does nothing if passed a link that is not recognized by the SDK. Non-Branch links may be passed for any domain that is configured for the app. This method does not pass the URL to the operating system or a browser.
Android note: If not using the newActivity
option, it is necessary to move
the call to the RNBranch.initSession
method to the main activity's onResume
method instead of onStart
:
@Override
protected void onResume() {
super.onResume();
RNBranch.initSession(getIntent().getData(), this);
}
branch.openURL(url, options)
url: A String containing a Branch link
options: (Optional) An object with keys to supply option values (see below)
newActivity: (Android) Finish the current activity before opening the link. Results in a new activity window. Ignored on iOS.
import branch from 'react-native-branch'
branch.openURL("https://myapp.app.link/xyz")
branch.openURL("https://myapp.app.link/xyz", {newActivity: true})
The Branch Universal Object represents an item of content in your app, e.g. an article, a video, a user profile or a post.
Here are a set of best practices to ensure that your analytics are correct, and your content is ranking on Spotlight effectively.
- Set the
canonicalIdentifier
to a unique, de-duped value across instances of the app. - Ensure that the
title
,contentDescription
andcontentImageUrl
properly represent the object. - Initialize the Branch Universal Object and call
userCompletedAction
with theRegisterViewEvent
on page load (incomponentDidMount
). - Call
showShareSheet
andgenerateShortLink
later in the life cycle, when the user takes an action that needs a link. - Call the additional object events (purchase, share completed, etc) when the corresponding user action is taken.
Practices to avoid:
- Don't set the same
title
,contentDescription
andcontentImageUrl
across all objects. - Don't wait to initialize the object and register views until the user goes to share.
- Don't wait to initialize the object until you conveniently need a link.
- Don't create many objects at once and register views in a loop.
The params object is returned by various linking methods including subscribe, getLatestReferringParams, and getFirstReferringParams. Params will contain any data associated with the Branch link that was clicked before the app session began.
Branch returns explicit parameters every time. Here is a list, and a description of what each represents.
~
denotes analytics+
denotes information added by Branch
Parameter | Meaning |
---|---|
~channel | The channel on which the link was shared, specified at link creation time |
~feature | The feature, such as invite or share , specified at link creation time |
~tags | Any tags, specified at link creation time |
~campaign | The campaign the link is associated with, specified at link creation time |
~stage | The stage, specified at link creation time |
~creation_source | Where the link was created ('API', 'Dashboard', 'SDK', 'iOS SDK', 'Android SDK', or 'Web SDK') |
~referring_link | The referring link that drove the install/open, if present |
~id | Automatically generated 18 digit ID number for the link that drove the install/open, if present |
+match_guaranteed | True or false as to whether the match was made with 100% accuracy |
+referrer | The referrer for the link click, if a link was clicked |
+phone_number | The phone number of the user, if the user texted himself/herself the app |
+is_first_session | Denotes whether this is the first session (install) or any other session (open) |
+clicked_branch_link | Denotes whether or not the user clicked a Branch link that triggered this session |
+click_timestamp | Epoch timestamp of when the click occurred |
+url | The full URL of the link that drove the install/open, if present (e.g. bnc.lt/m/abcde12345) |
See also Deep Link Routing on the Branch documentation site for more information.
Any additional data attached to the Branch link will be available unprefixed.
To create a Branch Universal Object, use the branch.createBranchUniversalObject
method. Note
that unlike the underlying SDKs, all parameters to the Branch Universal Object must be supplied
at creation. These parameters are not represented as properties on the JavaScript object
returned by this method. They are stored on the underlying native Branch Universal Object.
branch.createBranchUniversalObject(canonicalIdentifier, properties)
canonicalIdentifier: A string that uniquely identifies this item of content
properties: An object containing properties defining the Branch Universal Object. See
Branch Universal Object Properties for a list of
available properties.
A promise. On resolution, the promise returns an object with a number of methods, documented below.
import branch from 'react-native-branch'
let branchUniversalObject = await branch.createBranchUniversalObject('canonicalIdentifier', {
automaticallyListOnSpotlight: true,
metadata: {prop1: 'test', prop2: 'abc'},
title: 'Cool Content!',
contentDescription: 'Cool Content Description'})
We've added a series of custom events that you'll want to start tracking for rich analytics and targeting. Use this method to record events associated with a content item (Branch Universal Object).
branchUniversalObject.userCompletedAction(event, params)
event: A string representing a standard event from the list below or a custom event.
Event | Description |
---|---|
RegisterViewEvent | User viewed the object |
AddToWishlistEvent | User added the object to their wishlist |
AddToCartEvent | User added object to cart |
PurchaseInitiatedEvent | User started to check out |
PurchasedEvent | User purchased the item |
ShareInitiatedEvent | User started to share the object |
ShareCompletedEvent | User completed a share |
params: (Optional) A dictionary of custom key-value pairs to associate with this event.
import branch, {
AddToCartEvent,
AddToWishlistEvent,
PurchasedEvent,
PurchaseInitiatedEvent,
RegisterViewEvent,
ShareCompletedEvent,
ShareInitiatedEvent
} from 'react-native-branch'
let branchUniversalObject = await branch.createBranchUniversalObject(...)
branchUniversalObject.userCompletedAction(RegisterViewEvent)
branchUniversalObject.userCompletedAction('Custom Action', { key: 'value' })
To list content on Spotlight (iOS), the preferred practice is to set the automaticallyListOnSpotlight
property to true
in the createBranchUniversalObject
method and call userCompletedAction(RegisterViewEvent)
on the Branch Universal Object when the view appears. The content will be listed on Spotlight
when userCompletedAction
is called. There is also a listOnSpotlight()
method on the Branch Universal
Object that can be used for this purpose. Note that this method and the
automaticallyListOnSpotlight
property are ignored on Android.
Note: Listing on Spotlight requires adding CoreSpotlight.framework
to your
Xcode project.
branchUniversalObject.listOnSpotlight()
import branch, { RegisterViewEvent } from 'react-native-branch'
let branchUniversalObject = await branch.createBranchUniversalObject('canonicalIdentifier', {
automaticallyListOnSpotlight: true,
// other properties
})
branchUniversalObject.userCompletedAction(RegisterViewEvent)
or
import branch from 'react-native-branch'
let branchUniversalObject = await branch.createBranchUniversalObject(...)
branchUniversalObject.listOnSpotlight()
Once you've created your Branch Universal Object
, which is the reference to the content you're interested in, you can then get a link back to it with the mechanisms described below.
branchUniversalObject.generateShortUrl(linkProperties, controlParams)
linkProperties: An object containing properties to define the link. See Link
Properties Parameters for available properties.
controlParams: (Optional) An object containing control parameters to override
redirects specified in the Branch Dashboard. See
Control Parameters for a list of available parameters.
A promise. On resolution, the promise returns an object with the shape { url }
.
The url
property is a string containing the generated short URL.
import branch from `react-native-branch`
let branchUniversalObject = await branch.createBranchUniversalObject(...)
let linkProperties = { feature: 'share', channel: 'RNApp' }
let controlParams = { $desktop_url: 'http://example.com/home', $ios_url: 'http://example.com/ios' }
let {url} = await branchUniversalObject.generateShortUrl(linkProperties, controlParams)
Once you've created your Branch Universal Object
, which is the reference to the
content you're interested in, you can then automatically share it without having
to create a link using the mechanism below.
The Branch SDK includes a wrapper around the system share sheet that will generate a Branch short URL and automatically tag it with the channel the user selects (Facebook, Twitter, etc.). Note that certain channels restrict access to certain fields. For example, Facebook prohibits you from pre-populating a message.
branchUniversalObject.showShareSheet(shareOptions, linkProperties, controlParams)
*shareOptions: An object containing any of the following properties:
KEY | TYPE | MEANING |
---|---|---|
messageHeader | string |
The header text |
messageBody | string |
The body text |
emailSubject | string |
The subject of the email channel if selected |
linkProperties: An object containing properties to define the link. See Link
Properties Parameters for available properties.
controlParams: (Optional) An object containing control parameters to override
redirects specified in the Branch Dashboard. See
Control Parameters for a list of available parameters.
A promise. On resolution, the promise returns an object with the shape
{ channel, completed, error }
. The completed
property is a boolean specifying
whether the operation was completed by the user. The channel
property is a
string specifying the share channel selected by the user. The error
property
is a string. If non-null, it specifies any error that occurred.
import branch from `react-native-branch`
let branchUniversalObject = await branch.createBranchUniversalObject(...)
let linkProperties = { feature: 'share', channel: 'RNApp' }
let controlParams = { $desktop_url: 'http://example.com/home', $ios_url: 'http://example.com/ios' }
let shareOptions = { messageHeader: 'Check this out', messageBody: 'No really, check this out!' }
let {channel, completed, error} = await branchUniversalObject.showShareSheet(shareOptions, linkProperties, controlParams)
The Branch Universal Object is a construct in the underlying native SDK that is
exposed using a JavaScript object that is returned by the
createBranchUniversalObject
method. For best performance, call the release()
method on the Branch UniversalObject when the Branch Universal Object is no
longer in use. Native resources will eventually be reclaimed without calling
this method. Calling it ensures that the resources are reclaimed promptly.
branchUniversalObject.release()
import branch, { RegisterViewEvent } from `react-native-branch
class CustomComponent extends Component {
buo = null
componentDidMount() {
this.buo = await branch.createBranchUniversalObject(...)
this.buo.userCompletedAction(RegisterViewEvent)
}
componentWillUnmount() {
if (this.buo) {
this.buo.release()
this.buo = null
}
}
}
Key | TYPE | DESCRIPTION |
---|---|---|
automaticallyListOnSpotlight | Bool | List this item on Spotlight (iOS). Ignored on Android. |
canonicalIdentifier | String | The object identifier |
contentDescription | String | Object Description |
contentImageUrl | String | The Image URL |
contentIndexingMode | String | Indexing Mode 'private' or 'public' |
currency | String | A 3-letter ISO currency code (used with price) |
expirationDate | String | A UTC expiration date, e.g. 2018-02-01T00:00:00 |
keywords | Array | An array of keyword strings |
metadata | Object | Custom key/value |
price | Float | A floating-point price (used with currency) |
title | String | The object title |
type | String | MIME type for this content |
KEY | TYPE | MEANING |
---|---|---|
alias | string |
Specify a link alias in place of the standard encoded short URL (e.g., [branchsubdomain]/youralias or yourdomain.co/youralias) . Link aliases are unique, immutable objects that cannot be deleted. Aliases on the legacy bnc.lt domain are incompatible with Universal Links and Spotlight |
campaign | string |
Use this field to organize the links by actual campaign. For example, if you launched a new feature or product and want to run a campaign around that |
channel | string |
Use channel to tag the route that your link reaches users. For example, tag links with ‘Facebook’ or ‘LinkedIn’ to help track clicks and installs through those paths separately |
feature | string |
This is the feature of your app that the link might be associated with. eg: if you had built a referral program, you would label links with the feature referral |
stage | string |
Use this to categorize the progress or category of a user when the link was generated. For example, if you had an invite system accessible on level 1, level 3 and 5, you could differentiate links generated at each level with this parameter |
tags | array |
This is a free form entry with unlimited values. Use it to organize your link data with labels that don’t fit within the bounds of the above |
Specify control parameters in calls to generateShortUrl
and showShareSheet
.
All Branch control parameters are supported. See here for a complete list. In particular, these control parameters determine where the link redirects.
KEY | TYPE | MEANING |
---|---|---|
$fallback_url | string |
Change the redirect endpoint for all platforms - so you don’t have to enable it by platform |
$desktop_url | string |
Change the redirect endpoint on desktops |
$android_url | string |
Change the redirect endpoint for Android |
$ios_url | string |
Change the redirect endpoint for iOS |
$ipad_url | string |
Change the redirect endpoint for iPads |
$fire_url | string |
Change the redirect endpoint for Amazon Fire OS |
$blackberry_url | string |
Change the redirect endpoint for Blackberry OS |
$windows_phone_url | string |
Change the redirect endpoint for Windows OS |
Reward balances change randomly on the backend when certain actions are taken (defined by your rules), so you will need to make an asynchronous call to retrieve the balance.
branch.loadRewards()
import branch from 'react-native-branch'
let rewards = await branch.loadRewards()
Redeeming credits allows users to cash in the credits they've earned. Upon successful redemption, the user's balance will be updated reflecting the deduction.
branch.redeemRewards(amount, bucket)
amount: The amount to redeem
bucket: (Optional) The bucket to redeem from
import branch from 'react-native-branch'
let redeemResult = await branch.redeemRewards(amount, bucket)
This call will retrieve the entire history of credits and redemptions from the individual user.
branch.getCreditHistory()
A promise. On resolution, the promise returns an array containing the current user's credit history.
let creditHistory = await branch.getCreditHistory()