Successful marketing automation is essential to the future of your mobile app. Braze helps you engage your users beyond the download. Visit the following links for details and we'll have you up and running in no time!
The Braze Roku SDK will provide you with an API to report information to be used in analytics, segmentation, and engagement,
- Add
BrazeSDK.brs
to your app in thesource
directory. - Add
BrazeTask.brs
andBrazeTask.xml
to your app in thecomponents
directory.
Add a reference to BrazeSDK.brs
in your main scene using the following script
element:
<script type="text/brightscript" uri="pkg:/source/BrazeSDK.brs"/>
Within main.brs
, set the Braze configuration on the global node:
globalNode = screen.getGlobalNode()
config = {}
config_fields = BrazeConstants().BRAZE_CONFIG_FIELDS
config[config_fields.API_KEY] = "YOUR_API_KEY_HERE"
config[config_fields.ENDPOINT] = "YOUR_ENDPOINT_HERE (e.g. https://sdk.iad-01.braze.com/)"
config[config_fields.HEARTBEAT_FREQ_IN_SECONDS] = 5
globalNode.addFields({brazeConfig: config})
Initialize the Braze instance:
m.BrazeTask = createObject("roSGNode", "BrazeTask")
m.Braze = getBrazeInstance(m.BrazeTask)
To process in-app messages, you can add an observer on BrazeTask.BrazeInAppMessage
:
m.BrazeTask.observeField("BrazeInAppMessage", "onInAppMessageReceived")
Then within your handler, you have access to the highest in-app message that has been triggered by your campaigns:
in_app_message = m.BrazeTask.BrazeInAppMessage
You can then decide what to do with the in-app message. Some of the fields available:
in_app_message.message
- The body text of the in-app messagein_app_message.buttons
- List of buttons (could be an empty list).in_app_message.id
- ID to use when logging impressions or clicksin_app_message.extras
- Key/value pairsin_app_message.image_url
- Image URLin_app_message.click_action
- When there are no buttons, this is what should happen when the user clicks "OK" when the IAM is displayed. Can be "URI" or "NONE".in_app_message.dismiss_type
- Can be "AUTO_DISMISS" or "SWIPE"in_app_message.display_delay
- How long (in seconds) to wait until displaying the in-app messagein_app_message.duration
- How long (in milliseconds), the message should be displayed whendismiss_type
is "AUTO_DISMISS"in_app_message.header
- The header text of the in-app messagein_app_message.uri
- Whenclick_action
is "URI", this should be displayed
There are also various styling fields that you could choose to use from the dashboard. Alternatively, you could implement the In-App Message and style it within your Roku application using a standard palette.
in_app_message.bg_color
- Background colorin_app_message.close_button_color
- Close button colorin_app_message.frame_color
- The color of the background screen overlayin_app_message.header_text_color
- Header text colorin_app_message.message_text_color
- Message text colorin_app_message.text_align
- Can be "START", "CENTER", or "END"
Button fields include:
buttons[0].click_action
- Can be "URI" to indicate to open theuri
field. Can be "NONE" to indicate this button should close the in-app message.buttons[0].id
- The ID value of the button itselfbuttons[0].text
- The text to display on the buttonbuttons[0].uri
- Whenclick_action
is "URI", this should be displayedbuttons[0].bg_color
- Button background colorbuttons[0].border_color
- Button border colorbuttons[0].text_color
- Button text color
When a message is displayed or seen, log an impression:
LogInAppMessageImpression(in_app_message.id, brazetask)
Once a user clicks on the message, log a click:
LogInAppMessageClick(in_app_message.id, brazetask)
and then process in_app_message.click_action
If the user clicks on a button, log the button click:
LogInAppMessageButtonClick(inappmessage.id, inappmessage.buttons[selected].id, brazetask)
and then process inappmessage.buttons[selected].click_action
After processing in-app message, you should clear the field:
m.BrazeTask.BrazeInAppMessage = invalid
Braze should now be collecting data from your application. Please see our public documentation on how to log attributes, events, and purchases to our SDK. Our sample app's scene MainScene.brs
also contains examples of using the API.
BrazeInAppMessage.brs
and CustomSideBySideInAppMessage.brs
show examples of handling In-App Messages. onInAppMessageTriggered()
in MainScene.brs
shows how to support multiple layouts.
The directory torchietv
contains a sample app with the Braze SDK integrated.