• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL

EDIT ON GITHUB

Roku SDK reference

Read time: 1 minute
Last edited: Jul 28, 2021

This reference guide documents basic usage of our Roku SDK, and explains in detail how features work. If you want to dig even deeper, our SDKs are open source. To learn more, read Roku Client GitHub repository. The complete API reference is available here. Additionally you can clone and run a sample application using this SDK.

The Roku SDK is written in BrightScript.

Getting started

Building on top of our Getting Started guide, the following steps will get you started with using the LaunchDarkly SDK in your Roku Application.

We provide releases on GitHub. Download the latest release and extract the provided files into your source tree. You may need to rename the paths inside LaunchDarklyTask.xml depending on your project structure.

For SceneGraph usage add a LaunchDarklyTask node to your scene and then: <--And then what? What's happening in this code sample? TKTK

1REM get a reference to to task
2launchDarklyNode = m.top.findNode("my-node-name")
3
4REM create configuration
5config = LaunchDarklyConfig("MY_MOBILE_KEY", launchDarklyNode)
6
7REM create a user
8user = LaunchDarklyUser("user-key")
9
10REM initialize the client
11LaunchDarklySGInit(config, user)

For each SceneGraph component you want to use the SDK in you need to initialize an interface to talk to the SceneGraph. This interface provides all the expected client functionality such as evaluation.

Here's how:

1REM create the scenegraph communication wrapper
2launchDarkly = LaunchDarklySG(launchDarklyNode)
3
4REM use the client
5value = launchDarkly.boolVariation("MY_FLAG_KEY", false)

Creating a client outside of the SceneGraph API is similar. In the legacy API you do not need LaunchDarklySGInit or the LaunchDarklySG functions.

Here's how:

1REM get a reference to the task
2launchDarklyNode = m.top.findNode("MY_NODE_NAME")
3
4REM create configuration
5config = LaunchDarklyConfig("MY_MOBILE_KEY", launchDarklyNode)
6
7REM create a user
8user = LaunchDarklyUser("user-key")
9
10
11REM create message port
12messagePort = createObject("roMessagePort")
13
14REM initialize the client
15launchDarkly = LaunchDarkly(config, user, messagePort)
16
17
18REM use the client
19value = launchDarkly.boolVariation("MY_FLAG_KEY", false)

If not using the SceneGraph you need to poll events to drive the client in your standard event loop:

1while (true)
2
3 REM do not wait forever or timers will break
4 msg = wait(3000, messagePort)
5
6
7 if launchDarkly.handleMessage(msg) then
8 REM this message was for the client
9 else
10 REM handle non client messages
11 end if
12end while

Supported features

This SDK supports the following features: