Initialize the SDK

Overview

  1. In Visual Studio, open the main.brs file from the source folder.

  2. In the main.brs file, you'll see the 'client-application' scene as the first screen that is created and shown.

  3. Open scene.brs and create the OTinitialize node in the init() as m.global.OTsdk = CreateObject(“roSGNode”,”OTinitialize”)

  1. The OTinitialize id is the name of the component that is specified in OTinitialize.xml, which contains all the interfaces and their public methods as part of the SDK's controller component(s).
  1. Once created the OTsdk init(), the sdkParams values such as appId, location, language, and version need to be set and call the public method startSDK() in the OTinitialize.brs file. The declaration also prompts the SDK data download.
  1. Once it is downloaded, eventlistener "dataDownloadSuccess" will be triggered.

  2. You'll have access to all the setupUI public methods through m.global.OTsdk.callFunc("setupUI"), {"view":m.top, "type": "banner"}) for this given scene.

  3. If you want to have access to this public method across all scenes in the application, you'll need to enter and declare the OTsdk in a global method: m.global.OTsdk = CreateObject("roSGNode", "OTinitialize").

  4. By doing this global declaration, you won't need to declare another SDK initialization.

  5. This is also true if you want to set up global methods for each of the calls in the scene.brs file, to create global methods for all scenes.

  6. If you choose to call showBannerUI or showPreferenceCenterUI, then you will not have to call setupUI, "view", "type".

  7. Enable instant resume with the following manifest entries "sdk_instant_resume=1".

📘

For more information, see Roku's documentation Instant Resume.