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.
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 task2launchDarklyNode = m.top.findNode("my-node-name")34REM create configuration5config = LaunchDarklyConfig("MY_MOBILE_KEY", launchDarklyNode)67REM create a user8user = LaunchDarklyUser("user-key")910REM initialize the client11LaunchDarklySGInit(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.
1REM create the scenegraph communication wrapper2launchDarkly = LaunchDarklySG(launchDarklyNode)34REM use the client5value = 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
1REM get a reference to the task2launchDarklyNode = m.top.findNode("MY_NODE_NAME")34REM create configuration5config = LaunchDarklyConfig("MY_MOBILE_KEY", launchDarklyNode)67REM create a user8user = LaunchDarklyUser("user-key")91011REM create message port12messagePort = createObject("roMessagePort")1314REM initialize the client15launchDarkly = LaunchDarkly(config, user, messagePort)161718REM use the client19value = 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)23 REM do not wait forever or timers will break4 msg = wait(3000, messagePort)567 if launchDarkly.handleMessage(msg) then8 REM this message was for the client9 else10 REM handle non client messages11 end if12end while
This SDK supports the following features: