Initial SDK integration
This reference article covers how to install the Braze SDK for Roku. Installing the Braze Roku SDK will provide you with basic analytics and segmentation functionality.
Check out our sample Roku app on GitHub: TorchieTV.
Step 1: Add files
Braze SDK files can be found in the sdk_files
directory in the Braze Roku SDK repository.
- Add
BrazeSDK.brs
to your app in thesource
directory. - Add
BrazeTask.brs
andBrazeTask.xml
to your app in thecomponents
directory.
Step 2: Add references
Add a reference to BrazeSDK.brs
in your main scene using the following script
element:
1
<script type="text/brightscript" uri="pkg:/source/BrazeSDK.brs"/>
Step 3: Configure
Within main.brs
, set the Braze configuration on the global node:
1
2
3
4
5
6
7
8
globalNode = screen.getGlobalNode()
config = {}
config_fields = BrazeConstants().BRAZE_CONFIG_FIELDS
config[config_fields.API_KEY] = {YOUR_API_KEY}
' example endpoint: "https://sdk.iad-01.braze.com/"
config[config_fields.ENDPOINT] = {YOUR_ENDPOINT}
config[config_fields.HEARTBEAT_FREQ_IN_SECONDS] = 5
globalNode.addFields({brazeConfig: config})
You can find your SDK endpoint and API key within the Braze dashboard.
Step 4: Initialize Braze
Initialize the Braze instance:
1
2
m.BrazeTask = createObject("roSGNode", "BrazeTask")
m.Braze = getBrazeInstance(m.BrazeTask)
Enable Logging (optional)
To debug your Braze integration, you can view the Roku debug console for Braze logs. Refer to Debugging code from Roku Developers to learn more.
Basic SDK integration complete
Braze should now be collecting data from your application with the Braze Roku SDK.
See the following articles on how to log attributes, events, and purchases to our SDK.
To learn more about in-app messaging on Roku, see our in-app message integration guide.