Giter VIP home page Giter VIP logo

braze-roku-sdk's Introduction

Roku SDK

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!

Initial SDK Integration

The Braze Roku SDK will provide you with an API to report information to be used in analytics, segmentation, and engagement,

Step 1: Add Files

  1. Add BrazeSDK.brs to your app in the source directory.
  2. Add BrazeTask.brs and BrazeTask.xml to your app in the components directory.

Step 2: Add References

Add a reference to BrazeSDK.brs in your main scene using the following script element:

<script type="text/brightscript" uri="pkg:/source/BrazeSDK.brs"/>

Step 3: Configure

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})

Step 4: Initialize Braze

Initialize the Braze instance:

m.BrazeTask = createObject("roSGNode", "BrazeTask")
m.Braze = getBrazeInstance(m.BrazeTask)

In-App Message Setup

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 message
  • in_app_message.buttons - List of buttons (could be an empty list).
  • in_app_message.id - ID to use when logging impressions or clicks
  • in_app_message.extras - Key/value pairs
  • in_app_message.image_url - Image URL
  • in_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 message
  • in_app_message.duration - How long (in milliseconds), the message should be displayed when dismiss_type is "AUTO_DISMISS"
  • in_app_message.header - The header text of the in-app message
  • in_app_message.uri - When click_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 color
  • in_app_message.close_button_color - Close button color
  • in_app_message.frame_color - The color of the background screen overlay
  • in_app_message.header_text_color - Header text color
  • in_app_message.message_text_color - Message text color
  • in_app_message.text_align - Can be "START", "CENTER", or "END"

Button fields include:

  • buttons[0].click_action - Can be "URI" to indicate to open the uri field. Can be "NONE" to indicate this button should close the in-app message.
  • buttons[0].id - The ID value of the button itself
  • buttons[0].text - The text to display on the button
  • buttons[0].uri - When click_action is "URI", this should be displayed
  • buttons[0].bg_color - Button background color
  • buttons[0].border_color - Button border color
  • buttons[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

Basic SDK Integration Complete

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.

Additional Reference

The directory torchietv contains a sample app with the Braze SDK integrated.

braze-roku-sdk's People

Contributors

bryanlogan avatar bucimis avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

braze-roku-sdk's Issues

Can not disable logging

The braze SDK does not offer a way to disable logging. This can be frustrating for developers that are not actively working with the SDK in the project as it add noise to the logs. The SDK should offer a way to disable the logging. Ideally this could be a compile time constant or a configuration flag.

Braze SDK causes a circular reference

Due to the Braze SDK Task storing a reference to m.top in it's instance of the Braze "class" it is impossible to clean up the SDK. Happy to work with you on a solution to this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.