Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appstronauts-branch-cordova-sdk

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appstronauts-branch-cordova-sdk

Branch Metrics Cordova SDK

  • 3.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Branch for Cordova/PhoneGap/Ionic

Travis npm downloads npm version npm version

URLs can navigate to your website, but not to your app. Branch fixes this with deep links.

Branch will grow your app by allowing users to install, open, and navigate to content inside your app.

Increase discovery of your app by sharing its content, converting web users to app users, enabling user-to-user sharing, personalizing user experiences, tracking users, tracking referrals, tracking campaigns, tracking conversions, and increasing overall engagement.

Branch for Cordova, PhoneGap, and Ionic

Questions? Contact us

Getting Started

  • Configure Branch
  • Configure App
    • Cordova and Ionic

      <!-- sample config.xml -->
      <widget id="com.eneff.branch.cordovatestbed" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
        <!-- Branch -->
        <plugin name="branch-cordova-sdk" spec="^3.1.6" />
        <branch-config>
          <branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
          <uri-scheme value="branchcordova" />
          <link-domain value="cordova.app.link" />
          <ios-team-release value="PW4Q8885U7" />
        </branch-config>
      
    • PhoneGap

      <!-- sample config.xml -->
      <widget id="com.eneff.branch.cordovatestbed" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
        <!-- Branch -->
        <plugin name="branch-cordova-sdk" spec="^3.1.6" />
        <branch-config>
          <branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
          <uri-scheme value="branchcordova" />
          <link-domain value="cordova.app.link" />
          <ios-team-release value="PW4Q8885U7" />
        </branch-config>
      
    • Change the following values to match your Branch Dashboard

      • com.eneff.branch.cordovatestbed
      • key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3
      • branchcordova
      • cordova.app.link
      • PW4Q8885U7
  • Initialize Branch
    • Cordova and PhoneGap

      // sample index.js
      var app = {
        initialize: function() {
          app.bindEvents();
        },
        bindEvents: function() {
          document.addEventListener("deviceready", app.onDeviceReady, false);
          document.addEventListener("resume", app.onDeviceResume, false);
        },
        onDeviceReady: function() {
          app.branchInit();
        },
        onDeviceResume: function() {
          app.branchInit();
        },
        branchInit: function() {
          // Branch initialization
          Branch.initSession().then(function(data) {
            if (data["+clicked_branch_link"]) {
              // read deep link data on click
              alert("Deep Link Data: " + JSON.stringify(data));
            }
          });
        }
      };
      
      app.initialize();
      
    • Ionic 1

      // sample app.js
      angular
        .module("starter", ["ionic", "starter.controllers", "starter.services"])
      
        .run(function($ionicPlatform) {
          $ionicPlatform.ready(function() {
            if (
              window.cordova &&
              window.cordova.plugins &&
              window.cordova.plugins.Keyboard
            ) {
              cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
              cordova.plugins.Keyboard.disableScroll(true);
            }
            if (window.StatusBar) {
              StatusBar.styleDefault();
            }
      
            // Branch
            $ionicPlatform.on("deviceready", function() {
              branchInit();
            });
      
            $ionicPlatform.on("resume", function() {
              branchInit();
            });
      
            function branchInit() {
              // Branch initialization
              Branch.initSession().then(function(data) {
                if (data["+clicked_branch_link"]) {
                  // read deep link data on click
                  alert("Deep Link Data: " + JSON.stringify(data));
                }
              });
            }
          });
        });
      // ...
      
    • Ionic 2/3

      // sample app.component.js
      import { Component } from "@angular/core";
      import { Platform } from "ionic-angular";
      import { StatusBar, Splashscreen } from "ionic-native";
      
      import { TabsPage } from "../pages/tabs/tabs";
      
      @Component({
        template: `<ion-nav [root]="rootPage"></ion-nav>`
      })
      export class MyApp {
        rootPage = TabsPage;
      
        constructor(platform: Platform) {
          platform.ready().then(() => {
            StatusBar.styleDefault();
            Splashscreen.hide();
            branchInit();
          });
      
          platform.resume.subscribe(() => {
            branchInit();
          });
      
          // Branch initialization
          const branchInit = () => {
            // only on devices
            if (!platform.is("cordova")) {
              return;
            }
            const Branch = window["Branch"];
            Branch.initSession().then(data => {
              if (data["+clicked_branch_link"]) {
                // read deep link data on click
                alert("Deep Link Data: " + JSON.stringify(data));
              }
            });
          };
        }
      }
      
    • Create a deep link from the Branch Marketing Dashboard

    • Delete your app from the device

    • Compile your app (cordova run ios phonegap run ios ionic cordova run ios)

    • 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 Marketing Dashboard

    • Delete your app from the device

    • Compile your app (cordova run android phonegap run android ionic cordova run android)

    • Paste deep link in Google Hangouts

    • Click on the deep link to open your app

Features

  • Initialize Branch Features
    • Loads Branch into your app

    • Must be called on deviceready and resume

      // for development and debugging only
      Branch.setDebug(true);
      
      // for GDPR compliance (can be called at anytime)
      Branch.disabledTracking(false);
      
      // for better Android matching
      Branch.setCookieBasedMatching("cordova.app.link");
      
      // Branch initialization
      Branch.initSession().then(function(data) {
        if (data["+clicked_branch_link"]) {
          // read deep link data on click
          alert("Deep Link Data: " + JSON.stringify(data));
        }
      });
      
  • Create Content Reference
    • The Branch Universal Object encapsulates the thing you want to share (content or user)

    • Link Data: Universal Object Properties

      // only canonicalIdentifier is required
      var properties = {
        canonicalIdentifier: "content/123",
        canonicalUrl: "https://example.com/content/123",
        title: "Content 123 Title",
        contentDescription: "Content 123 Description " + Date.now(),
        contentImageUrl: "http://lorempixel.com/400/400/",
        price: 12.12,
        currency: "GBD",
        contentIndexingMode: "private",
        contentMetadata: {
          custom: "data",
          testing: 123,
          this_is: true
        }
      };
      
      // create a branchUniversalObj variable to reference with other Branch methods
      var branchUniversalObj = null;
      Branch.createBranchUniversalObject(properties)
        .then(function(res) {
          branchUniversalObj = res;
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
    • Creates a deep link URL with encapsulated data

    • Needs a Branch Universal Object

    • Link Data: Deep Link Properties

    • Verify on the Branch Dashboard

    • All function's parameters are mandatory

      // optional fields
      var analytics = {
        channel: "facebook",
        feature: "onboarding",
        campaign: "content 123 launch",
        stage: "new user",
        tags: ["one", "two", "three"]
      };
      
      // optional fields
      var properties = {
        $desktop_url: "http://www.example.com/desktop",
        $android_url: "http://www.example.com/android",
        $ios_url: "http://www.example.com/ios",
        $ipad_url: "http://www.example.com/ipad",
        $deeplink_path: "content/123",
        $match_duration: 2000,
        custom_string: "data",
        custom_integer: Date.now(),
        custom_boolean: true
      };
      
      branchUniversalObj
        .generateShortUrl(analytics, properties)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res.url));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
    • Will generate a Branch deep link and tag it with the channel the user selects

    • Needs a Branch Universal Object

    • Link Data: Deep Link Properties

    • All function's parameters are mandatory

      // optional fields
      var analytics = {
        channel: "facebook",
        feature: "onboarding",
        campaign: "content 123 launch",
        stage: "new user",
        tags: ["one", "two", "three"]
      };
      
      // optional fields
      var properties = {
        $desktop_url: "http://www.example.com/desktop",
        custom_string: "data",
        custom_integer: Date.now(),
        custom_boolean: true
      };
      
      var message = "Check out this link";
      
      // optional listeners (must be called before showShareSheet)
      branchUniversalObj.onShareSheetLaunched(function(res) {
        // android only
        console.log(res);
      });
      branchUniversalObj.onShareSheetDismissed(function(res) {
        console.log(res);
      });
      branchUniversalObj.onLinkShareResponse(function(res) {
        console.log(res);
      });
      branchUniversalObj.onChannelSelected(function(res) {
        // android only
        console.log(res);
      });
      
      // share sheet
      branchUniversalObj.showShareSheet(analytics, properties, message);
      
    • Retrieve Branch data from a deep link

    • Best practice to receive data from the listener

    • Listener

      // Branch initialization within your deviceready and resume
      Branch.initSession()
        .then(function success(res) {
          if (res["+clicked_branch_link"]) {
            alert("Open app with a Branch deep link: " + JSON.stringify(res));
            // Branch quick link: https://cordova.app.link/uJcOH1IFpM
            // Branch web link: https://cordova-alternate.app.link/uJcOH1IFpM
            // Branch dynamic link: https://cordova.app.link?tags=one&tags=two&tags=three&channel=Copy&feature=onboarding&stage=new+user&campaign=content+123+launch&type=0&duration=0&source=android&data
            // Branch uri scheme: branchcordova://open?link_click_id=link-500015444967786346
            // Branch android intent: intent://open?link_click_id=518106399270344237#Intent;scheme=looprocks;package=com.eneff.branch.cordovatestbed;S.browser_fallback_url=https%3A%2F%2Fcordova.app.link%2FuJcOH1IFpM%3F__branch_flow_type%3Dchrome_deepview%26__branch_flow_id%3D518106399312287278;S.market_referrer=link_click_id-518106399270344237%26utm_source%3DCopy%26utm_campaign%3Dcontent%20123%20launch%26utm_feature%3Donboarding;S.branch_data=%7B%22~feature%22%3A%22onboarding%22%2C%22this_is%22%3A%22true%22%2C%22custom_string%22%3A%22data%22%2C%22testing%22%3A%22123%22%2C%22%24publicly_indexable%22%3A%22false%22%2C%22%24desktop_url%22%3A%22http%3A%2F%2Fwww.example.com%2Fdesktop%22%2C%22%24one_time_use%22%3Afalse%2C%22custom_object%22%3A%22%7B%5C%5C%5C%22random%5C%5C%5C%22%3A%5C%5C%5C%22dictionary%5C%5C%5C%22%7D%22%2C%22~id%22%3A%22517795540654792902%22%2C%22~campaign%22%3A%22content%20123%20launch%22%2C%22%2Bclick_timestamp%22%3A1524764418%2C%22%2Burl%22%3A%22https%3A%2F%2Fcordova.app.link%2FuJcOH1IFpM%22%2C%22custom_boolean%22%3A%22true%22%2C%22custom%22%3A%22data%22%2C%22source%22%3A%22android%22%2C%22%24og_image_url%22%3A%22http%3A%2F%2Florempixel.com%2F400%2F400%2F%22%2C%22%2Bdomain%22%3A%22cordova.app.link%22%2C%22custom_integer%22%3A%221524690301794%22%2C%22~tags%22%3A%5B%22one%22%2C%22two%22%2C%22three%22%5D%2C%22custom_array%22%3A%22%5B1%2C2%2C3%2C4%2C5%5D%22%2C%22~channel%22%3A%22Copy%22%2C%22~creation_source%22%3A2%2C%22%24canonical_identifier%22%3A%22content%2F123%22%2C%22%24og_title%22%3A%22Content%20123%20Title%22%2C%22%24og_description%22%3A%22Content%20123%20Description%201524690296449%22%2C%22%24identity_id%22%3A%22453670943617990547%22%2C%22~stage%22%3A%22new%20user%22%2C%22%2Bclicked_branch_link%22%3Atrue%2C%22%2Bmatch_guaranteed%22%3Atrue%2C%22%2Bis_first_session%22%3Afalse%7D;B.branch_intent=true;end
            // Branch android app link (device controlled): https://cordova.app.link/uJcOH1IFpM
            // Branch ios universal link (device controlled): https://cordova.app.link/uJcOH1IFpM
          } else if (res["+non_branch_link"]) {
            alert("Open app with a non Branch deep link: " + JSON.stringify(res));
            // Competitor uri scheme: anotherurischeme://hello=world
          } else {
            alert("Open app organically");
            // Clicking on app icon or push notification
          }
        })
        .catch(function error(err) {
          logger(err, true);
        });
      
    • First data

      Branch.getFirstReferringParams()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
    • Latest data

      Branch.getLatestReferringParams()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
  • Display Content
    • List content on iOS Spotlight

    • Needs a Branch Universal Object

      branchUniversalObj
        .listOnSpotlight()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
  • Track Content
    • Track how many times a user views a particular piece of content

    • Needs a Branch Universal Object

    • Verify on the Branch Dashboard

      branchUniversalObj
        .registerView()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
  • Track User
    • Sets the identity of a user (email, ID, UUID, etc) for events, deep links, and referrals

    • Verify on the Branch Dashboard

      var userId = "123456";
      Branch.setIdentity(userId)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err.message));
        });
      
    • Removes the identity of a user

      Branch.logout()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err.message));
        });
      
  • Track Event
    • Registers a custom event

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

    • Recommended to Track User before Track Event to associate custom events with a user

    • Verify on the Branch Dashboard

      var eventName = "clicked_on_this";
      var metadata = { custom_dictionary: 123, anything: "everything" };
      Branch.userCompletedAction(eventName, metadata)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err.message));
        });
      
      var eventName = "clicked_on_this";
      Branch.userCompletedAction(eventName)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err.message));
        });
      
  • Track Commerce
    • Registers a custom commerce event

    • Link Data: Track commerce properties for Currency and Category

    • Verify on the Branch Dashboard

      // only revenue is required
      var event = {
        revenue: 50.29,
        currency: 148, // USD
        transactionID: "transaction id",
        coupon: "coupon",
        shipping: 2.22,
        tax: 5.11,
        affiliation: "affiliation",
        products: [
          {
            sku: "u123",
            name: "cactus",
            price: 4.99,
            quantity: 2,
            brand: "brand",
            category: 17, // Software
            variant: "variant"
          },
          {
            sku: "u456",
            name: "grass",
            price: 0.0,
            quantity: 1
          }
        ]
      };
      
      // optional fields
      var metadata = {
        custom_dictionary: 123,
        anything: "everything"
      };
      
      Branch.sendCommerceEvent(event, metadata)
        .then(function(res) {
          console.log(res);
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          console.error(err);
          alert("Error: " + JSON.stringify(err.message));
        });
      
  • Handle Referrals
    • Referral points are obtained from events triggered by users from rules created on the Branch Dashboard

    • Verify on the Branch Dashboard

    • Get credits

    • Spend credits

      var amount = 10;
      var bucket = "this_bucket";
      Branch.redeemRewards(amount, bucket)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
      var amount = 10;
      Branch.redeemRewards(amount)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
    • Load credits

      var bucket = "this_bucket";
      Branch.loadRewards(bucket)
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
      Branch.loadRewards()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      
    • Load history

      Branch.creditHistory()
        .then(function(res) {
          alert("Response: " + JSON.stringify(res));
        })
        .catch(function(err) {
          alert("Error: " + JSON.stringify(err));
        });
      

Troubleshooting

  • Testing: Key Points
    • Need to select "app uses IDFA and GAID" when publishing your app

    • Best to enable Deepviews (Testing: Supported Platforms)

    • Mobile browser capability: Android 4.4.4+, Safari 8+, Chrome 32+, Firefox 29+

  • Testing: Optional App Config
    <!-- sample config.xml -->
    <widget id="com.eneff.branch.cordovatestbed" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <!-- Branch -->
      <plugin name="branch-cordova-sdk" spec="~2.4.2" /> <!-- optional spec -->
      <branch-config>
        <branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
        <uri-scheme value="branchcordova" />
        <link-domain value="yourcustomdomain.com" />
        <link-domain value="cordova.app.link" />  <!-- optional previous link domain -->
        <link-domain value="bnc.lt" />  <!-- optional previous link domain -->
        <ios-team-release value="PW4Q8885U7" /> <!-- required if iOS app -->
        <ios-team-debug value="FG35JLLMXX" /> <!-- optional -->
        <android-prefix value="/WSuf" /> <!-- optional (for bnc.lt link domains) -->
        <android-testmode value="true" /> <!-- optional (simulate installs) -->
      </branch-config>
    
    <widget ios-CFBundleIdentifier="com.eneff.branch.cordovatestbedios" android-packageName="com.eneff.branch.cordovatestbedandroid" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    
  • Testing: Branch Analytics
    • Whenever a user clicks on a deep link and opens the app, and will trigger either an install or an open

    • installs represent Branch recognizing the app_id and device_id for the first time

    • installs represent new app users and the success rate of your Branch deep links

    • installs do not represent App Store downloads

    • non-Branch installs are installs outside of Branch deep link clicks

    • opens are non-installs

    • If a user uninstalls and reinstalls the app, this will be an open because Branch recognizes the device

    • If a user has the app and clicks a Branch deep link, this will be an open because the user is not new

  • Testing: Simulating an Install
    • Delete your app

    • [iOS] iPhone Device -> Settings -> Privacy -> Advertising -> Reset Advertising Identifier -> Reset Identifier

    • [Android] Add <android-testmode value="true" /> to your Config.xml (Testing: Optional App Config)

    • Add Branch.setDebug(true); before Branch.initSession(); (Initialize Branch Features)

    • Click on a deep link to navigate to your $fallback_url because your app is not installed

    • Install your app

    • Open your app

    • Read from Branch.initSession(data) for +is_first_session = true

  • Testing: Supported Platforms
    • Apps which support Branch deep links

      iOSDetailsAndroidDetails
      Facebook NewsFeedWorks when DeepViews are enabled
      Facebook MessangerWorks when DeepViews are enabled
      Twitter
      PinterestWorks when DeepViews are enabled
      Slack
      Chrome address bar🅾️🅾️
      Chrome web page
      FireFox address bar🅾️🅾️
      FireFox web page
      Safari address bar🅾️
      Safari web page
      WeChatWorks when DeepViews are enabled
      WhatsAppapp.link requires https/http to be clickableapp.link requires https/http to be clickable
      Hangouts
      iMessage
      Apple Mail
      Gmail
  • Testing: Sample Testing App
    • For Create Content Reference

    • Properties

      KeyDefaultUsageLink Property
      canonicalIdentifier(Required) This is the unique identifier for content that will help Branch dedupe across many instances of the same thing. Suitable options: a website with pathing, or a database with identifiers for entities$canonical_identifier
      canonicalUrlThe canonical URL, used for SEO purposes$canonical_url
      titleThe name for the piece of content$og_title
      contentDescriptionA description for the content$og_description
      contentImageUrlThe image URL for the content. Must be an absolute path$og_image_url
      priceThe price of the item$amount
      currencyThe currency representing the price in ISO 4217 currency code$currency
      contentIndexingMode"public"Can be set to either "public" or "private". Public indicates that you’d like this content to be discovered by other apps.$publicly_indexable
      contentMetadataAny custom key-value data e.g. { "custom": "data" }
    • For Create Deep Link and Share Deep Link

    • Analytics

      KeyDefaultUsage
      channelUse 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
      featureThis is the feature of your app that the link might be associated with. For example, if you had built a referral program, you would label links with the feature ‘referral’
      campaignUse 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
      stageUse 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
      tagsThis is a free form entry with unlimited values ["string"]. Use it to organize your link data with labels that don’t fit within the bounds of the above
      aliasSpecify a link alias in place of the standard encoded short URL e.g. yourdomain.com/youralias. Link aliases are unique, immutable objects that cannot be deleted. You cannot change the alias of existing links. Aliases on the legacy bnc.lt domain are incompatible with Universal Links and Spotlight
      type0Set to 1 to limit deep linking behavior of the generated link to a single use. Set type to 2 to make the link show up under Marketing Dashboard while adding $marketing_title to data. Must be an int. Does not work with the Cordova SDK (limitation of native SDKs)
    • Properties

      • Custom Data

        KeyValueUsage
        random123Any key-value pair
        hello"world"Any key-value pair
        custom_datatrueAny key-value pair
      • Redirection

        KeyDefaultUsage
        $fallback_urlChange the redirect endpoint for all platforms - so you don’t have to enable it by platform. Note that Branch will forward all robots to this URL, which overrides any OG tags entered in the link. System-wide Default URL (set in Link Settings)
        $desktop_urlChange the redirect endpoint on desktops Text-Me-The-App page (set in Link Settings)
        $ios_urlChange the redirect endpoint for iOS App Store page for your app (set in Link Settings)
        $ipad_urlChange the redirect endpoint for iPads $ios_url value
        $android_urlChange the redirect endpoint for Android Play Store page for your app (set in Link Settings)
        $windows_phone_urlChange the redirect endpoint for Windows OS Windows Phone default URL (set in Link Settings)
        $blackberry_urlChange the redirect endpoint for Blackberry OS BlackBerry default URL (set in Link Settings)
        $fire_urlChange the redirect endpoint for Amazon Fire OS Fire default URL (set in Link Settings)
        $ios_wechat_urlChange the redirect endpoint for WeChat on iOS devices $ios_url value
        $android_wechat_urlChange the redirect endpoint for WeChat on Android devices $android_url value
        $after_click_urlURL redirect to after the main click redirect has completed
        $web_onlyfalseForce to open the $fallback_url instead of the app
      • Deep Link

        KeyDefaultUsage
        $deeplink_pathopen?link_click_id=1234Set the deep link path for all platforms - so you don’t have to enable it by platform. When the Branch SDK receives a link with this parameter set, it will automatically load the custom URI path contained within
        $android_deeplink_pathSet the deep link path for Android apps When the Branch SDK receives a link with this parameter set, it will automatically load the custom URI path contained within
        $ios_deeplink_pathSet the deep link path for iOS apps. When the Branch SDK receives a link with this parameter set, it will automatically load the custom URI path contained within
        $match_duration7200Lets you control the fingerprinting match timeout (the time that a click will wait for an app open to match) also known as attribution window. Specified in seconds
        $always_deeplinktrueSet to false to make links always fall back to your mobile site. Does not apply to Universal Links or Android App Links.
        $ios_redirect_timeout750Control the timeout that the client-side JS waits after trying to open up the app before redirecting to the App Store. Specified in milliseconds
        $android_redirect_timeout750Control the timeout that the clientside JS waits after trying to open up the app before redirecting to the Play Store. Specified in milliseconds
        $one_time_usefalseSet to true to limit deep linking behavior of the generated link to a single use. Can also be set using type
        $custom_sms_textText for SMS link sent for desktop clicks to this link. Must contain {{ link }} Value of Text me the app page in Settings
        $marketing_titleThe Marketing Title for the deep link in the Marketing Dashboard
      • Content

        KeyDefaultUsage
        $publicly_indexable1Cannot modify here. Needs to be set by the Branch Universal Object
        $keywordsKeywords for which this content should be discovered by. Just assign an array of strings with the keywords you’d like to use
        $canonical_identifierThis is the unique identifier for content that will help Branch dedupe across many instances of the same thing. Suitable options: a website with pathing, or a database with identifiers for entities
        $exp_date0Cannot modify here. Needs to be set by the Branch Universal Object. Must be epoch timestamp with milliseconds
        $content_typeThis is a label for the type of content present. Apple recommends that you use uniform type identifier as described here
      • DeepView

        KeyDefaultUsage
        $ios_deepviewdefault_templateThe name of the deepview template to use for iOS
        $android_deepviewdefault_templateThe name of the deepview template to use for Android
        $desktop_deepviewdefault_templateThe name of the deepview template to use for the Desktop
      • Open Graph

        KeyDefaultUsage
        $og_titleSet the title of the link as it will be seen in social media displays
        $og_descriptionSet the description of the link as it will be seen in social media displays
        $og_image_urlSet the image of the link as it will be seen in social media displays
        $og_image_widthSet the image’s width in pixels for social media displays
        $og_image_heightSet the image’s height in pixels for social media displays
        $og_videoSet a video as it will be seen in social media displays
        $og_urlSet the base URL of the link as it will be seen in social media displays
        $og_typeSet the type of custom card format link as it will be seen in social media displays
        $og_redirect(Advanced, not recommended) Set a custom URL that we redirect the social media robots to in order to retrieve all the appropriate tags
        $og_app_id(Rarely used) Sets the app id tag
      • Twitter

        KeyDefaultUsage
        $twitter_cardSet the Twitter card type of the link
        $twitter_titleSet the title of the Twitter card
        $twitter_descriptionSet the description of the Twitter card
        $twitter_image_urlSet the image URL for the Twitter card
        $twitter_siteSet the site for Twitter
        $twitter_app_countrySet the app country for the app card
        $twitter_playerSet the video player’s URL. Defaults to the value of $og_video.
        $twitter_player_widthSet the player’s width in pixels
        $twitter_player_heightSet the player’s height in pixels
    • For Track Commerce

    • Categories

      ValueCategory
      0Animals & Pet Supplies
      1Apparel & Accessories
      2Arts & Entertainment
      3Baby & Toddler
      4Business & Industrial
      5Camera & Optics
      6Electronics
      7Food, Beverage & Tobacco
      8Furniture
      9Hardware
      10Health & Beauty
      11Home & Garden
      12Luggage & Bags
      13Mature
      14Media
      15Office Supplies
      16Religious & Ceremonial
      17Software
      18Sporting Goods
      19Toys & Games
      20Vehicles & Parts
    • Currencies

      ValueCurrency
      0AED
      1AFN
      2ALL
      3AMD
      4ANG
      5AOA
      6ARS
      7AUD
      8AWG
      9AZN
      10BAM
      11BBD
      12BDT
      13BGN
      14BHD
      15BIF
      16BMD
      17BND
      18BOB
      19BOV
      20BRL
      21BSD
      22BTN
      23BWP
      24BYN
      25BYR
      26BZD
      27CAD
      28CDF
      29CHE
      30CHF
      31CHW
      32CLF
      33CLP
      34CNY
      35COP
      36COU
      37CRC
      38CUC
      39CUP
      40CVE
      41CZK
      42DJF
      43DKK
      44DOP
      45DZD
      46EGP
      47ERN
      48ETB
      49EUR
      50FJD
      51FKP
      52GBP
      53GEL
      54GHS
      55GIP
      56GMD
      57GNF
      58GTQ
      59GYD
      60HKD
      61HNL
      62HRK
      63HTG
      64HUF
      65IDR
      66ILS
      67INR
      68IQD
      69IRR
      70ISK
      71JMD
      72JOD
      73JPY
      74KES
      75KGS
      76KHR
      77KMF
      78KPW
      79KRW
      80KWD
      81KYD
      82KZT
      83LAK
      84LBP
      85LKR
      86LRD
      87LSL
      88LYD
      89MAD
      90MDL
      91MGA
      92MKD
      93MMK
      94MNT
      95MOP
      96MRO
      97MUR
      98MVR
      99MWK
      100MXN
      101MXV
      102MYR
      103MZN
      104NAD
      105NGN
      106NIO
      107NOK
      108NPR
      109NZD
      110OMR
      111PAB
      112PEN
      113PGK
      114PHP
      115PKR
      116PLN
      117PYG
      118QAR
      119RON
      120RSD
      121RUB
      122RWF
      123SAR
      124SBD
      125SCR
      126SDG
      127SEK
      128SGD
      129SHP
      130SLL
      131SOS
      132SRD
      133SSP
      134STD
      135SYP
      136SZL
      137THB
      138TJS
      139TMT
      140TND
      141TOP
      142TRY
      143TTD
      144TWD
      145TZS
      146UAH
      147UGX
      148USD
      149USN
      150UYI
      151UYU
      152UZS
      153VEF
      154VND
      155VUV
      156WST
      157XAF
      158XAG
      159XAU
      160XBA
      161XBB
      162XBC
      163XBD
      164XCD
      165XDR
      166XFU
      167XOF
      168XPD
      169XPF
      170XPT
      171XSU
      172XTS
      173XUA
      174XXX
      175YER
      176ZAR
      177ZMW
    • Sync with Mixpanel if plugin is installed

      Branch.setRequestMetadata("$mixpanel_distinct_id", "123");
      
  • Compiling: Cordova Dependencies
    • Node

      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
      brew update;
      brew install node;
      
    • Xcode

      • Install Xcode

      • Open Xcode -> agree to SDK license agreement

      • Open Xcode -> Create new Xcode project -> Run simulator -> Agree to developer mode on mac

    • Android Studio

      • Read instructions

      • Install JVM

      • Install Android Studio

      • Open Android Studio -> configure -> appearance/system settings/android sdk -> android 6.0 -> Okay

      • Open Android Studio -> New project -> ... -> Run -> Create new emulator -> Nexus 6p 23 -> Finish

        # add to ~/.bash_profile
        export ANDROID_HOME=$HOME/Library/Android/sdk
        export PATH=$ANDROID_HOME/tools:$PATH
        export PATH=$ANDROID_HOME/platform-tools:$PATH
        
        source ~/.bash_profile;
        
        android update sdk;
        
      • Install Android SDK build-tools 24.0.1

      • Generate Android Keystore

        keytool -genkeypair -dname "cn=Full Name, ou=Business Unit, o=Company, c=US" -alias release -keypass aaa111 -keystore release.keystore -storepass aaa111 -validity 10000
        keytool -list -v -keystore release.keystore
        
    • Genymotion [optional]

      • Install Virtual Box

      • Install Genymotion

      • Genymotion -> Add virtual device -> Google Nexus 6P - 6.0.0 - API 23 -> Next

  • Compiling: Show Console Logs
    • iOS Simulator

      • cordova run ios;

      • Safari -> Preferences -> Advance -> Show Develop menu in menu bar

      • Safari -> Develop -> Simulator -> index.html -> Console

      • May need to unplug and replug device

      • May need to open Xcode and update provisioning profile

    • iOS Xcode

      • cordova plugin add cordova-plugin-console;

      • cordova build ios;

      • Xcode -> APP_LOCATION/platforms/ios/APP_NAME.Xcodeproj

      • Xcode -> App -> General -> Signing -> Team

      • Xcode -> Product -> Run

      • Xcode -> View -> Debug Area -> Activate Console

    • Android Device

    • Android Genymotion

  • Compiling: Updating the Branch SDK
    # terminal
    cordova plugin remove io.branch.sdk
    cordova plugin remove branch-cordova-sdk
    
    <!-- config.xml -->
    <plugin name="branch-cordova-sdk" spec="^2.6.0" />
    
  • Compiling: Incompatible Plugins
  • Compiling: Errors
    • Migrating Branch Cordova SDK from v2.5+ to v3.0+
      // Branch initialization
      - Branch.initSession(function(data) {
      + Branch.initSession().then(function(data) {
        if (data["+clicked_branch_link"]) {
          // read deep link data on click
          alert("Deep Link Data: " + JSON.stringify(data));
        }
      });
      
    • error

      ORIGINAL EXCEPTION: Branch is not defined
      
      ReferenceError: Branch is not defined
      
      • Branch opens and installs your app. You cannot simulate Branch in the desktop browser

        // Ionic 2/3 - running on browser instead of device
        if (!platform.is("cordova")) {
          return;
        }
        Branch.userCompletedAction("did_this");
        
        // Ionic 2/3 - missing Branch import
        declare var Branch;
        
    • error

      ** ARCHIVE FAILED **
      
      The following build commands failed:
        Check dependencies
      (1 failure)
      Error: Error code 65 for command: xcodebuild with args: -xcconfig,cordova/build-debug.xcconfig,-workspace,Branch Testing.xcworkspace,-scheme,Branch Testing,-configuration,Debug,-destination,generic/platform=iOS,-archivePath,Branch Testing.xcarchive,archive,CONFIGURATION_BUILD_DIR=build/device,SHARED_PRECOMPS_DIR=build/sharedpch
      
      • Open app in Xcode and launch from there (to select a Provisioning Profile)
    • error

      An invalid value 'XC com eneff branch cordova_testbed' was provided for the parameter 'appIdName'.
      
      No profiles for 'com.eneff.branch.cordova_testbed' were found
      
      • Don't use cordova, hyphens (Android), or underscores (iOS) in your bundle id (widget id)
      Error: Error code 1 for command: /gradlew with args: cdvBuildDebug,-b,/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
      
      • Add <preference name="android-minSdkVersion" value="16" /> to your config.xml

FAQs

Package last updated on 21 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc