Nonstop Brightscript SDK

Initialization

Initialize the Nonstop SDK after your Main Scene has been created but before doing anything else in your app.

Initialization

The Nonstop SDK takes the form of a Node with is attached to the global object which you can then call functions on to perform certain actions. To initialize the SDK, create an instance of this node and then set the following fields:

  • environment - this should be set to either dev, staging, qa or production depending on the build of the app
  • fontsDir - this should be a path to the directory containing the required fonts for the SDK in your app. The current font stack contains Avenir and Futura.
  • amplitudeConfig - provides configuration for the Amplitude tracking the SDK performs internally. Please see the docs on Amplitude for more information.

Then call the Initialize function on the Nonstop node.

Example

main.brs:

sub main()
    ? "[main] showMainScreen"
    m.port = CreateObject("roMessagePort")

    m.screen = CreateObject("roSGScreen")
    m.screen.setMessagePort(m.port)
    m.scene = m.screen.CreateScene("MainScene")
    m.screen.Show()

    m.global = m.screen.getGlobalNode()

    m.scene.callFunc("startApplication", {})
    while(true)
        msg = wait(0, m.port)
        if not processMessage(msg) then exit while
    end while

    if screen <> invalid then
        screen.Close()
        screen = invalid
    end if
end sub

MainScene.brs:

function startApplication(params as Object)
    ? "[MainScene] startApplication"
    nonstop = m.top.createChild("Nonstop")
    nonstop.environment = "dev"
    nonstop.fontsDir = "pkg:/fonts/"

    amplitudeConfig = createObject("roSGNode", "amplitudeConfig")
    amplitudeConfig.setField("apiKey", "357ab438c26e31f044db2aab0da4d3c9")
    amplitudeConfig.setField("session_id", 0)
    amplitudeConfig.setField("device_id", "device_id_set")
    nonstop.amplitudeConfig = amplitudeConfig

    nonstop.callFunc("Initalize")
end function

Environments

The Environments parameter controls which APIs the SDK will hit, and thus which Nonstop Admin and ShowMS Environment is tied to them. Developers should be conscious of this and match their Nonstop Environment to their ShowMS environment for the given build.

Reward Animations

Note: The Nonstop SDK will asynchronously preload reward animations on initialize for improved performance when they are required so you may see this network call on app start.

In this document