Packageio.branch.nativeExtensions.branch
Classpublic class Branch
InheritanceBranch Inheritance flash.events.EventDispatcher

Main interface to the Branch SDK for the Branch native extension.



Public Properties
 PropertyDefined By
  implementation : String
[read-only] The implementation currently in use.
Branch
  instance : Branch
[static] [read-only]
Branch
  isSupported : Boolean
[static] [read-only] Whether the current device supports the extensions functionality
Branch
  nativeVersion : String
[read-only] The native version string of the native extension.
Branch
  version : String
[read-only] The version of this extension.
Branch
Public Methods
 MethodDefined By
  
Branch is a Singleton, it should be access through the Branch.instance reference.
Branch
  
Branch
  
disableTracking(disabled:Boolean):Boolean
TODO
Branch
  
dispose():void
Disposes the extension and releases any allocated resources.
Branch
  
getCredits(bucket:String):void
Reward balances change randomly on the backend when certain actions are taken (defined by your rules), so it'll make an asynchronous call to retrieve the balance.
Branch
  
getCreditsHistory(bucket:String):void
This call will retrieve the entire history of credits and redemptions from the individual user.
Branch
  
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.
Branch
  
[static]
Branch
  
These session parameters will be available at any point later on with this command.
Branch
  
handleDeepLink(link:String, forceNewSession:Boolean = true):void
Allows you to deep link into your own app from your app itself Warning: Handling a new deep link in your app will clear the current session data and a new referred "open" will be attributed.
Branch
  
init(useTestKey:Boolean = false):void
Deprecated: Use initSession( options )
Initialise the Branch SDK.
Branch
  
initSession(options:BranchOptions = null):void
Initialise the Branch SDK and start a session.
Branch
  
logEvent(event:Object):Boolean
Logs an event to Branch for tracking and analytics You should use a BranchEventBuilder to construct the parameter for this function.
Branch
  
logout():void
If you provide a logout function in your app, be sure to clear the user when the logout completes.
Branch
  
redeemRewards(credits:int, bucket:String):void
We will store how many of the rewards have been deployed so that you don't have to track it on your end.
Branch
  
setIdentity(userId:String):void
Often, you might have your own user IDs, or want referral and event data to persist across platforms or uninstall/reinstall.
Branch
  
userCompletedAction(action:String, stateStringifiedJSON:String = {}):void
Register Custom Events
Branch
  
This will attempt to validate the current application's Branch integration and will output results to the device log This is for testing in development only! Make sure you remove or comment out this line of code in your release versions.
Branch
Events
 Event Summary Defined By
   Dispatched when the getCredits has failed.Branch
   Dispatched when the getCredits method is called and SUCCESS.Branch
   Dispatched when the getCreditsHistory has failed.Branch
   Dispatched when the getCreditsHistory method is called and SUCCESS.Branch
   Dispatched when the getShortUrl has failed.Branch
   Dispatched when the short url has been successfully created.Branch
   Dispatched when the key init has failed.Branch
   Dispatched when the key has been successfully set up.Branch
   Dispatched when the redeemRewards has failed.Branch
   Dispatched when the redeemRewards has SUCCESS.Branch
   Dispatched when the identity set up has failed.Branch
   Dispatched when the identity has been successfully set up.Branch
Public Constants
 ConstantDefined By
  EXT_CONTEXT_ID : String = io.branch.nativeExtensions.Branch
[static]
Branch
  VERSION : String = 5.4.0
[static]
Branch
Property Detail
implementationproperty
implementation:String  [read-only]

The implementation currently in use. This should be one of the following depending on the platform in use and the functionality supported by this extension:


Implementation
    public function get implementation():String
instanceproperty 
instance:Branch  [read-only]


Implementation
    public static function get instance():Branch
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether the current device supports the extensions functionality


Implementation
    public static function get isSupported():Boolean
nativeVersionproperty 
nativeVersion:String  [read-only]

The native version string of the native extension.


Implementation
    public function get nativeVersion():String
versionproperty 
version:String  [read-only]

The version of this extension.

This should be of the format, MAJOR.MINOR.BUILD


Implementation
    public function get version():String
Constructor Detail
Branch()Constructor
public function Branch()

Branch is a Singleton, it should be access through the Branch.instance reference.

Method Detail
createUniversalObject()method
public function createUniversalObject():BranchUniversalObject

Returns
BranchUniversalObject
disableTracking()method 
public function disableTracking(disabled:Boolean):Boolean

TODO

Parameters

disabled:Boolean

Returns
Boolean
dispose()method 
public function dispose():void

Disposes the extension and releases any allocated resources. Once this function has been called, the extension functionality will have to be re-initialised upon next use.

getCredits()method 
public function getCredits(bucket:String):void

Reward balances change randomly on the backend when certain actions are taken (defined by your rules), so it'll make an asynchronous call to retrieve the balance. Be sure to listen GET_CREDITS event.

Parameters

bucket:String — The bucket to get credits balance from.

getCreditsHistory()method 
public function getCreditsHistory(bucket:String):void

This call will retrieve the entire history of credits and redemptions from the individual user. Be sure to listen GET_CREDITS_HISTORY_SUCCESS and GET_CREDITS_HISTORY_FAILED events.

Parameters

bucket:String — The bucket to get credits balance from.

getFirstReferringParams()method 
public function getFirstReferringParams():String

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 or something.

Returns
String — a String with installParams, turn it into a JSON.
getInstance()method 
public static function getInstance():Branch

Returns
Branch
getLatestReferringParams()method 
public function getLatestReferringParams():String

These session parameters will be available at any point later on with this command. If no params, the dictionary will be empty. This refreshes with every new session (app installs AND app opens).

Returns
String — a String with sessionParams, turn it into a JSON.
handleDeepLink()method 
public function handleDeepLink(link:String, forceNewSession:Boolean = true):void

Allows you to deep link into your own app from your app itself

Warning: Handling a new deep link in your app will clear the current session data and a new referred "open" will be attributed.

Parameters

link:String — The deep link
 
forceNewSession:Boolean (default = true) — If true a new session is created

init()method 
public function init(useTestKey:Boolean = false):void
Deprecated: Use initSession( options )

Initialise the Branch SDK.

Note: You should use initSession( options:BranchOptions ) to get access to the updated Branch features.

Parameters

useTestKey:Boolean (default = false) — Set it to true to use the key test.

initSession()method 
public function initSession(options:BranchOptions = null):void

Initialise the Branch SDK and start a session.

You will get the deep linked params associated with the link that the user clicked before showing up via the BranchEvent.INIT_SUCCESS event.

Parameters

options:BranchOptions (default = null)

See also


Example
This example shows how to set the test mode and delay initialisation to check for search ads.
         Branch.instance.initSession(
            new BranchOptions()
                .setUseTestKey()
                .setDelayInitToCheckForSearchAds()
         );
         
logEvent()method 
public function logEvent(event:Object):Boolean

Logs an event to Branch for tracking and analytics

You should use a BranchEventBuilder to construct the parameter for this function.

Parameters

event:Object — An object representing the Branch event

Returns
Booleantrue if the event is logged to Branch

See also


Example
To log a standard event:
         Branch.instance.logEvent(
            new BranchEventBuilder( BranchEventBuilder.STANDARD_EVENT_PURCHASE )
                .setCurrency( "USD" )
                .setRevenue( 1.23 )
                .build()
         );
         
To log a custom event "your_custom_event":
         Branch.instance.logEvent(
            new BranchEventBuilder( "your_custom_event" )
                .addCustomDataProperty("your_custom_key", "your_custom_value")
                .build()
         );
         
logout()method 
public function logout():void

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 referral credits and attribution on the device.

redeemRewards()method 
public function redeemRewards(credits:int, bucket:String):void

We will store how many of the rewards have been deployed so that you don't have to track it on your end. In order to save that you gave the credits to the user, you can call redeem. Redemptions will reduce the balance of outstanding credits permanently.

Parameters

credits:int — credits given to the user.
 
bucket:String — The bucket to get credits balance from.

setIdentity()method 
public function setIdentity(userId:String):void

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'.

Parameters

userId:String — Identify a user, with his user id.

userCompletedAction()method 
public function userCompletedAction(action:String, stateStringifiedJSON:String = {}):void

Register Custom Events

Parameters

action:String
 
stateStringifiedJSON:String (default = {}) — Store some state with the event, a stringified JSON.

validateIntegration()method 
public function validateIntegration():void

This will attempt to validate the current application's Branch integration and will output results to the device log

This is for testing in development only! Make sure you remove or comment out this line of code in your release versions.

Event Detail
getcredits:failed Event
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.GET_CREDITS_FAILED

Dispatched when the getCredits has failed. See event's data for details.
getcredits:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.GET_CREDITS_SUCCESS

Dispatched when the getCredits method is called and SUCCESS. See event's data for details.
getcreditshistory:failed Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.GET_CREDITS_HISTORY_FAILED

Dispatched when the getCreditsHistory has failed. See event's data for details.
getcreditshistory:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.GET_CREDITS_HISTORY_SUCCESS

Dispatched when the getCreditsHistory method is called and SUCCESS. See event's data for details.
getshorturl:failed Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.GET_SHORT_URL_FAILED

Dispatched when the getShortUrl has failed. See event's data for details.
getshorturl:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.GET_SHORT_URL_SUCCESS

Dispatched when the short url has been successfully created. See event's data for the result.
init:failed Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.INIT_FAILED

Dispatched when the key init has failed. See event's data for details.
init:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.INIT_SUCCESS

Dispatched when the key has been successfully set up. See event's data for referringParams.
redeemrewards:failed Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.REDEEM_REWARDS_FAILED

Dispatched when the redeemRewards has failed. See event's data for details.
redeemrewards:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchCreditsEvent
BranchCreditsEvent.type property = io.branch.nativeExtensions.branch.events.BranchCreditsEvent.REDEEM_REWARDS_SUCCESS

Dispatched when the redeemRewards has SUCCESS.
setidentity:failed Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.SET_IDENTITY_FAILED

Dispatched when the identity set up has failed. See event's data for details.
setidentity:success Event  
Event Object Type: io.branch.nativeExtensions.branch.events.BranchEvent
BranchEvent.type property = io.branch.nativeExtensions.branch.events.BranchEvent.SET_IDENTITY_SUCCESS

Dispatched when the identity has been successfully set up.
Constant Detail
EXT_CONTEXT_IDConstant
public static const EXT_CONTEXT_ID:String = io.branch.nativeExtensions.Branch

VERSIONConstant 
public static const VERSION:String = 5.4.0