Roku SDK reference
Read time: 1 minute
Last edited: Sep 24, 2021
This reference guide documents basic usage of our Roku SDK, and explains in detail how features work. LaunchDarkly's SDKs are open source. To learn more, read Roku Client GitHub repository. You can also try this SDK out by cloning and running a sample application.
The Roku SDK is written in BrightScript.
After you complete the Getting Started process, follow these instructions to start 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.
To create a client instance, you need your environment's mobile key, available in the Projects tab of your account settings page. Be sure to use a mobile key. Never embed a server-side SDK key into a mobile application.
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)
You must make feature flags available to client-side SDKs before the flags can be evaluated. If you evaluate a feature flag that is not available, you receive the default value for that flag. If you want a project's flags to be made available to this SDK by default, check the SDKs using Mobile key checkbox in your project Settings.
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: