Roku Basic Integration

Include Required Library files

  1. BranchSdkLibrary.brs
  2. BranchSdkTask.xml
  3. BranchSdkTask.brs

Within the input folder, you will find the following required Branch SDK files:

├── components
│   └── tasks
│       ├── BranchSdkTask.brs
│       └── BranchSdkTask.xml
└── source
    └── libs
        └── BranchSdkLibrary.brs
  1. Create a new folder called libs in the source folder of your application
  2. Copy the BranchSdkLibrary.brs file from the Branch repo into your project's new libs folder
  3. Create a new folder called tasks in components folder of your
    application
  4. Copy both the BranchSdkTask.xml and BranchSdkTask.brs files into your project's new
    tasks folder

Configure Branch

  1. Open the Main.brs file of your project which functions as the entry point of SceneGraph application.
  2. Inside the sub Main(), add the following line: ConfigureBranchSdk(screen) (example here)
  3. Next, let's define a new sub below Main()
sub ConfigureBranchSdk(screen as dynamic)
    options = {}
    ' For future use for advance features in Branch SDK'
    options.branchKey = "key_live_TODO_YOUR_BRANCH_KEY_HERE"
    options.logLevel = BranchSdkConstants().LOG_LEVEL.DEBUG
    options.environment = BranchSdkConstants().ENVIRONMENT.PRODUCTION

    ' Set Branch SDK configuration parameter as required
    screen.getGlobalNode().addFields({branchSdkConfig: options})
end sub

Then be sure to replace key_live_TODO_YOUR_BRANCH_KEY_HERE with your Branch Key from the Branch Dashboard.

You can see an example of this code here.

Initialize Branch

  1. Open your file which extends Scene, let say its MainScene.xml file.
  2. Add new script file path of BranchSdkLibrary.brs
<script type="text/brightscript" uri="pkg:/source/libs/BranchSdkLibrary.brs"/>

You can see an example of this code here.

  1. Open MainScene.brs file and create instance of the Branch SDK library:
m.branchSdkObj = CreateBranchSdkForSceneGraphApp()

You can see an example of this code here.

  1. Now do first API call which is InitSession like following:
m.branchSdkObj.initSession(m.global.launchArgs, "OnInitSessionCallbackFunc")

You can see an example of this code here. An example of the callback function can be found here

That's it! Now Roku session count tracking should function, and you'll start to see Roku installs and opens tracked on the Branch Dashboard!

Deep Linking and Attribution

There are two primary ways in which links can trigger the Roku app to respond. Here are curls that indicate the format of these links, which you can modify and use for testing:

  1. /launch/{channel}
curl -d '' 'http://ROKU_LOCAL_IP:8060/launch/dev?contentId=1234&mediaType=movie'
  1. /input
curl -d '' 'http://ROKU_LOCAL_IP:8060/input?contentId=1234&mediaType=movie'

where ROKU_LOCAL_IP is your Roku's local IP address.

In both cases, please send up the data (contentId, mediaType, and any other query params) to Branch:

m.branchSdkObj.handleInput(data, "OnHandleInputEventCallbackFunc")

Then you can receive deep link data back from Branch's servers, similar to any other Branch SDK. You can see an example of this code here and here.

📘

Important note

For proper deep linking, please make sure that you are using a correct deeplink format, e.g.: contentId=1234&mediaType=movie

Be sure to discuss your use cases for deep linking and attribution with a Branch team member.

Updated 4 months ago


Roku Basic Integration


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.