Adobe AIR

Integrate Branch

  • Configure Branch

  • Configure app

    In your project’s *-app.xml file, insert the platform-specific snippet(s) below. Change YOUR URI SCHEME to the URI scheme you’ve selected.

    • iOS

          <!-- other stuff -->
          <string>key_live_YOUR BRANCH KEY</string>
          <!-- Put your URI scheme below -->
                      <string>YOUR URI SCHEME</string>
    • Android

          <!-- other stuff -->
              <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_YOUR BRANCH KEY" />
                      <data android:scheme="YOUR URI SCHEME" />
                      <action android:name="android.intent.action.VIEW" />
                      <category android:name="android.intent.category.DEFAULT" />
                      <category android:name="android.intent.category.BROWSABLE" />
              <activity android:name="io.branch.nativeExtensions.branch.BranchActivity" android:launchMode="singleTask" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
  • Initialize Branch


    // Import
    import io.branch.nativeExtensions.branch.Branch;
    import io.branch.nativeExtensions.branch.BranchEvent;
    // Then create a Branch instance:
    var branch:Branch = new Branch();
    // Register two events before initializing the SDK:
    branch.addEventListener(BranchEvent.INIT_FAILED, initFailed);
    branch.addEventListener(BranchEvent.INIT_SUCCESSED, initSuccessed);
    private function initFailed(bEvt:BranchEvent):void {
        trace("BranchEvent.INIT_FAILED", bEvt.informations);
    private function initSuccessed(bEvt:BranchEvent):void {
        trace("BranchEvent.INIT_SUCCESSED", bEvt.informations);
        // params are the deep linked params associated with the link that the user clicked before showing up
        // params will be empty if no data found
        var referringParams:Object = JSON.parse(bEvt.informations);
    // Initialize the SDK:


    Be sure to have the INIT_SUCCESSED event called, otherwise read the bEvt.informations from the INIT_FAILED event.

  • Compiling ANE

    • To compile this ANE, you need to have ANT installed on your (OS X) machine, and Java 1.6.

    • Clone the repository, and change the build.config to match your computer settings with the path to your AIR SDK (you should have the latest one), to the Android SDK, and to a keystore (a certificate for Air, which may be a self-signed certificate created with adt).

    • Finally open a command line, cd in the directory and just call ant.

    • Create a deep link from the Branch Dashboard

    • Delete your app from the device

    • Compile and test on a device

    • 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

  • //be sure to add the event listeners:
    branch.addEventListener(BranchEvent.GET_SHORT_URL_FAILED, getShortUrlFailed);
    branch.addEventListener(BranchEvent.GET_SHORT_URL_SUCCESSED, getShortUrlSuccessed);
    private function getShortUrlSuccessed(bEvt:BranchEvent):void {
        trace("BranchEvent.GET_SHORT_URL_SUCCESSED", "my short url is: " + bEvt.informations);
    private function getShortUrlFailed(bEvt:BranchEvent):void {
        trace("BranchEvent.GET_SHORT_URL_FAILED", bEvt.informations);
    var dataToInclude:Object = {
      "article_id": "1234",
      "$og_title": "Hot off the presses!",
      "$og_image_url": "",
      "$desktop_url": ""
    branch.getShortUrl(tags, "sms", BranchConst.FEATURE_TAG_SHARE, JSON.stringify(dataToInclude));

    Deep linking is not fully supported at the moment

    Deferred deep linking will still pass data through install, but if the user already has the app installed, the user must click the Branch link twice to pass data. Recommended use case: referrals.

    • Returns deep link properties

    • Install & Open

      var sessionParams:String = branch.getLatestReferringParams();
      var sessionParamsObj:Object = JSON.parse(sessionParams);
    • Install Only

      var installParams:String = branch.getFirstReferringParams();
      var installParamsObj:Object = JSON.parse(installParams);

  • Track users

    branch.setIdentity("your user id");
  • Handle referrals

    • Referral points are obtained from events triggered by users from rules created on the Branch Dashboard

    • Validate on the Branch Dashboard

    • Reward credits with the Referral guide

    • Redeem credits

    • Load credits

    • Load history


Troubleshoot issues

  • Sample app

    You can find a full sample app in the main open source repo for the Air ANE. Visit the Github page here.