Search specific term/phrase surrounded by double quotes. e.g. “deep linking”
Exclude records that contain a specific term prefixed with a minus. e.g. Android -Firebase

Roku Full Reference

All available methods of Branch for your Roku app.

initSession

MethodDescription
initSession: function(inputArgs = {}, callbackFunc = "") as voidInitializes your Branch session.
ArgumentTypeDescription
inputArgsObjectInput arguments. Typically m.global.launchArgs
callbackFuncStringName of the callback function for initialization.

Example Usage

sub init()
    ' Other init Configs...'

    ' BRANCH SDK INTEGRATION - Create Instance'
  m.branchSdkObj = CreateBranchSdkForSceneGraphApp()

  if (m.branchSdkObj = invalid) then
    ShowMessageDialog("Failed to initialize Branch SDK!")
  else
    ' BRANCH SDK INTEGRATION - Initialize Branch'
    m.branchSdkObj.initSession(m.global.launchArgs, "OnInitSessionCallbackFunc")
  end if
    
    ' Other init Configs...'
end sub


function OnInitSessionCallbackFunc(event as object) as void
    data = event.GetData()
  print "OnInitSessionCallbackFunc: " data
    
  if (data <> invalid) then
    m.lSessionApiResultDetails.text = FormatJson(data)
  else
    m.lSessionApiResultDetails.text = "initSession API response received!"
  end if
    
  message = "API Succeeded!"
  if (data.error <> invalid)
    message = "API Error!"
  else
    ShowMessageDialog("initSession" + " " + message)
  end if
end function

setPreinstallData

MethodDescription
setPreinstallData: function(campaign = "", partner = "") as voidIf your app is preinstalled on Roku devices, for builds distributed to Roku, use this method to set configuration settings for your Branch session to attribute the pre-install to a specific partner.
ArgumentTypeDescription
campaignStringName of the campaign.
partnerStringName of the partner. This will typically be a $3p value. Reach out to your Branch account manager to retrieve the $3p value.
sub init()
    ' BRANCH SDK INTEGRATION - Create Instance'
    m.branchSdkObj = CreateBranchSdkForSceneGraphApp()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Failed to initialize Branch SDK!")
    else
        print "MainScene : setPreinstallData"
        ' BRANCH SDK INTEGRATION - Call API'
        m.branchSdkObj.setPreinstallData("MyCampaign", "MyPartner")
        InitSession_Clicked()
    end if
end sub

handleInput

MethodDescription
handleInput: function(inputArgs = {}, callbackFunc = "") as voidHandles an input to retrieve deep linking data
ArgumentTypeDescription
inputArgsObjectInput arguments. Typically m.global.launchArgs.
callbackFuncStringName of the callback function for initialization.

Example Usage

sub HandleInput_Clicked()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Branch SDK is not initialized!")
        return
    end if

    print "Calling Branch HandleInput API"
    print "m.global.launchArgs : " m.global.launchArgs
    if (m.global.launchArgs <> invalid) then
        ' BRANCH SDK INTEGRATION - Call API'
        m.branchSdkObj.handleInput(m.global.launchArgs, "OnHandleInputCallbackFunc")
    else
        ShowMessageDialog("Please provide deepLinking arguments!")
    end if
end sub
      
function OnHandleInputCallbackFunc(event as object) as void
    data = event.GetData()
    print "OnHandleInputCallbackFunc: " data
    m.global.launchArgs = invalid
    message = "API Succeeded!"
    if (data.error <> invalid)
        message = "API Error!"
    end if
    ShowMessageDialog("handleInput" + " " + message)
end function

logEvent

ArgumentTypeDescription
nameStringName of the event. List of compatible events can be found here.
customer_event_aliasStringThe alias of your event.
transaction_idStringThe ID of of your event.
currencyStringThe currency value of your event. List of compatible events can be found here.
revenueStringThe revenue of your event.
callbackFuncStringName of the callback function for your event.

Example Usage

sub LogEventPurchase_Clicked()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Branch SDK is not initialized!")
        return
    end if

    print "Calling Branch LogEvent Standard API"
    ' BRANCH SDK INTEGRATION - Call API'
    m.branchSdkObj.logEvent(BranchSdkConstants().EVENT_TYPE.PURCHASE, "My First Purchase as customer_event_alias", "transaction_id", "INR", 99.99, "OnLogEventPurchaseCallbackFunc")
end sub

function OnLogEventPurchaseCallbackFunc(event as object) as void
    data = event.GetData()
    print "OnLogEventPurchaseCallbackFunc: " data
    message = "API Succeeded!"
    if (data.error <> invalid)
        message = "API Error!"
    end if
    ShowMessageDialog("logEvent Purchase" + " " + message)
end function

disableTracking

MethodDescription
disableTracking: function(isDisable as boolean) as voidIf you need to comply with a user's request to not be tracked for GDPR purposes, or otherwise determine that a user should not be tracked, utilize this field to prevent Branch from sending network requests.
ArgumentTypeDescription
isDisablebooleanSet to true to disable tracking. Set to false to enable tracking.

Example Usage

sub init()
    m.bTracking.observeField("buttonSelected", "Tracking_Clicked")

    ' m.bInitSession.setFocus(true)'
    m.bSetIdentity.setFocus(true)

    ' BRANCH SDK INTEGRATION - Create Instance'
    m.branchSdkObj = CreateBranchSdkForSceneGraphApp()
end sub

sub Tracking_Clicked()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Branch SDK is not initialized!")
        return
    end if

    print "Calling Branch Tracking API"
    ' BRANCH SDK INTEGRATION - Call API'
    m.branchSdkObj.disableTracking(m.IsTracking)
    m.IsTracking = not m.IsTracking
    SetTrackingButtonText()
end sub

setIdentity

MethodDescription
setIdentity: function(developer_identity = "", callbackFunc = "") as voidSets the identity of the user. Typically performed when the user logs in.
ArgumentTypeDescription
developer_identityStringThe ID of the user logging in.
callbackFuncStringName of the callback function for setting identity.

Example Usage

sub init()
    m.bSetIdentity.observeField("buttonSelected", "SetIdentity_Clicked")

    ' m.bInitSession.setFocus(true)'
    m.bSetIdentity.setFocus(true)

    ' BRANCH SDK INTEGRATION - Create Instance'
    m.branchSdkObj = CreateBranchSdkForSceneGraphApp()

    SetTrackingButtonText()
end sub

sub SetIdentity_Clicked()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Branch SDK is not initialized!")
        return
    end if

    print "Calling Branch SetIdentity API"
    ' BRANCH SDK INTEGRATION - Call API'
    m.branchSdkObj.setIdentity("User123", "OnSetIdentityCallbackFunc")
end sub

logout

MethodDescription
logout: function(callbackFunc = "") as voidRemoves the identity set from setIdentity. Typically used when the user logs out.
ArgumentTypeDescription
callbackFuncStringName of the callback function for removing identity.

Example Usage

sub init()
    m.bLogout.observeField("buttonSelected", "Logout_Clicked")

    ' m.bInitSession.setFocus(true)'
    m.bSetIdentity.setFocus(true)

    ' BRANCH SDK INTEGRATION - Create Instance'
    m.branchSdkObj = CreateBranchSdkForSceneGraphApp()

    SetTrackingButtonText()
end sub

sub Logout_Clicked()
    if (m.branchSdkObj = invalid) then
        ShowMessageDialog("Branch SDK is not initialized!")
        return
    end if

    print "Calling Branch Logout API"
    ' BRANCH SDK INTEGRATION - Call API'
    m.branchSdkObj.logout("OnLogoutCallbackFunc")
end sub