Skip to content


Integrate Branch

  • Configure Branch

  • Configure App

    • iOS

      • Add your Branch key and register a URI scheme

        • In your project’s tiapp.xml file, insert the snippet below. Change yourapp to the URI scheme you’ve selected.
                       <!-- Add domains to support Universal Links -->
                   <!-- Add branch key as key-value pair -->
                   <!-- Add unique string for direct deep links -->
                   <!-- Required step for Universal Links on cold start -->
    • Android

      • Add your Branch Key and register a URI Scheme

        • Open your tiapp.xml and add the following tag:

                  <!-- Other existing entries -->
                  <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_xxxxxxxxxxxxxxx" />

        • Within your Deep Link Activity's definition, insert the intent filter provided below. Change yourapp under android:scheme to the URI scheme you’ve selected.

              <data android:scheme="yourapp" android:host="open" />
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
  • Initialize Branch

    • Initialize the SDK by inserting the following snippet into your index.js file:

      $.initialize = function(params) {
   "start initSession");
             branch.addEventListener("bio:initSession", $.onInitSessionFinished);
             if (OS_ANDROID) {
                 Ti.Android.currentActivity.addEventListener("newintent", function(e) {
           "inside newintent: " + e);
             if (OS_IOS) { // Don't forget this condition.
                var activity = Ti.App.iOS.createUserActivity({
                Ti.App.iOS.addEventListener('continueactivity', function(e) {
                    if (e.activityType === 'io.branch.testbed.universalLink') {
                        branch.continueUserActivity(e.activityType, e.webpageURL, e.userInfo);
         $.onInitSessionFinished = function(data) {
   "inside onInitSessionFinished");
             for (key in data) {
                 if ((key != "type" && key != "source" && key != "bubbles" && key != "cancelBubble") && data[key] != null) {
            + data["key"]);
    • Create a deep link from the Branch Marketing Dashboard

    • Delete your app from the device

    • Compile your app

    • Paste deep link in Apple Notes

    • Long press on the deep link (not 3D Touch)

    • Click Open in "APP_NAME" to open your app (example)

    • Create a deep link from the Branch Dashboard

    • Delete your app from the device

    • Compile your app

    • Paste deep link in Google Hangouts

    • Click on the deep link to open your app

Implement features

  • Create content reference

    • The Branch Universal Object encapsulates the thing you want to share

    • Uses the Universal Object Properties listed below:

      Key Type Meaning
      canonicalIdentifier string The identifier of the object
      title string The title of the object
      contentDescription string The short description of the object
      contentImageUrl string URL of the image used by the object
      contentIndexingMode string Indexing mode of the object. Set as "private" or "public".
      contentMetadata dictionary Custom keys and values as metadata of the object
          var branchUniversalObject = branch.createBranchUniversalObject({
              "canonicalIdentifier" : "content/12345",
              "title" : "My Content Title",
              "contentDescription" : "My Content Description",
              "contentImageUrl" : "",
              "contentIndexingMode" : "public",
              "contentMetadata" : {
                  "product_picture" : "12345",
                  "user_id" : "6789"
  •     branchUniversalObject.generateShortUrl({
          "feature" : "sample-feature",
          "channel" : "sample-channel",
          "stage" : "sample-stage"
        }, {
          "$desktop_url" : "",
        }, function (res) {
  'Completed link generation');
    • The event listener bio:generateShortUrl returns a string object containing the generated link:
          branchUniversalObject.addEventListener("bio:generateShortUrl", $.onGenerateUrlFinished);
    • Will generate a Branch deep link and tag it with the channel the user selects

    • Needs a Branch Universal Object

    • Uses Deep Link Properties

          "feature" : "sample-feature",
          "channel" : "sample-channel",
          "stage" : "sample-stage",
        }, {
          "$desktop_url" : "",
    • Android only (Callbacks in iOS are ignored. There is no need to implement them as the events are handled by UIActivityViewController)
        branchUniversalObject.shareLinkDialogLaunched(function () {
          console.log('Share sheet launched');
        branchUniversalObject.shareLinkDialogDismissed(function () {
         console.log('Share sheet dimissed');
        branchUniversalObject.shareLinkResponse(function (res) {
          console.log('Share link response: ' + JSON.stringify(res));
        branchUniversalObject.shareChannelSelected(function (res) {
          console.log('Channel selected: ' + JSON.stringify(res));
  • Track content

  • Track users

    • Sets the identity of a user (email, ID, UUID, etc) for events, deep links, and referrals

    • Validate with the Branch Dashboard

          var userId = '123456';
    • Removes the identity of a user

  • Track events

    • Registers a custom event

    • Events named open, close, install, and referred session are Branch restricted

    • Best to Track users before Track events to associate a custom event to a user

    • Validate with the Branch Dashboard

        var eventName = 'clicked_on_this';
  • Handle referral

        int value = 10;
    • Load credits
        var bucket = 'this_bucket'

    To implement the callback, you must add a listener to the event bio:loadRewards. The event returns a dictionary object containing the balance.

  • Load history


    Implement the callback, by adding a listener to the event bio:getCreditHistory.

Troubleshoot issues