Roku SDK Setup
A complete guide to the basics of adding Nami to your Roku App
Please make sure you have completed the setup of your app on the Nami Control Center for all these steps to be successful.
Adding Nami to your Roku channel has a few steps:
- Add the SDK to your project
- Configure the Nami SDK
- Show a paywall
We'll run through each of these below.
Demo app
The Demo app provides a reference example for using the Nami Roku SDK.
Add the SDK to your channel
- Download the file NamiSDKIntegrationHelper.brs from the nami-roku GitHub repository. You can put it in the same level as application’s MainScene component file.
- Include this file in MainScene component by pasting the following line in the script
section of scene’s XML file:
-
<script type="text/brightscript" uri="NamiSDKIntegrationHelper.brs" />
It is optional to put
NamiSDKIntegrationHelper.brs
file in the same level as the MainScene, however, if the path is different then make sure to edit the uri of the file in the above line.
- Add a
appData.json
to your project if you don't have one, with the following keys.
{
"namiSDKPath": "https://packages.namiml.com/NamiSDK/Roku/NamiRoku.pkg",
"appPlatformIdProduction": "YOUR_PRODUCTION_APP_PLATFORM_ID",
"appPlatformIdStaging": "YOUR_STAGING_APP_PLATFORM_ID",
"environment": "production",
"fonts": {
"opensans_bold": "pkg:/source/fonts/opensans_bold.ttf",
"opensans_regular": "pkg:/source/fonts/opensans_regular.ttf"
}
}
Configure the Nami SDK
In the sample NamiSDKIntegrationHelper.brs
implementation, the Nami SDK is configured using the App Platform ID value(s) found in appData.json
To set up or find your Roku App Platform ID(s), see the the Nami Control Center > Integrations as setup for Roku.
Organizing Nami Instance for Production and Staging
If you want to segregate your Nami organization to have separate environment for Production and Staging, you can create two apps.
Each app will need a Roku integration setup. In this scenario, you will end up with two App Platform IDs for each environment that can be put in their respective keys in the
appData.json
The
NamiSDKIntegrationHelper.brs
selects the App Platform ID to use based upon the value ofnamiEnvironment
fromappData.json
.You can modify this behavior your specific environments by adjusting
addData.json
andNamiSDKIntegrationHelper.brs
In addition, you can configure the SDK by setting some of the addition namiConfig
parameters.
' appPlatformId is set from the appData.json
appPlatformId = m.global.namiAppPlatformId
' Create NamiConfiguration object and configure it with required data
m.namiConfig = m.namiSDK.CreateChild("namiSDK:NamiConfiguration")
m.namiConfig.callFunc("configuration", appPlatformId)
m.namiConfig.logLevel = "debug"
m.nami = m.namiSDK.CreateChild("namiSDK:Nami")
configureStatus = m.nami.callFunc("configure", m.namiConfig)
Launch a Campaign to Raise a Paywall
To show a paywall, launch a campaign.
m.scene = m.top.getScene()
m.namiSDK = m.scene.findNode("namiSDK")
m.namiCampaignManager = m.namiSDK.findNode("NamiCampaignManagerObj")
m.namiCampaignManager.unobserveField("campaignLaunchHandler")
m.namiCampaignManager.observeField("campaignLaunchHandler", "OnCampaignLaunchHandler")
m.namiCampaignManager.callFunc("launchWithLabel", "onboarding")
Managing Identity
Provide the Nami SDK your customer identifier for a user to link their devices for cross-platform entitlements, subscriber analytics, audience targeting, and more.
Login - link a device to a known customer identifier
Attach a user's identity when they register or signs-in to their account in your app.
Logout - unlink device from customer identifier
You can disconnect the association between a user's device and a customer identifier.
For example, do this when the user logs out of their account within your app.
If provided, the customer identifier will be returned in any individual level data from Nami web hooks or REST API in the
external_id
fieldNami also uses customer id to establish a cross-platform view of a subscriber for analytics reporting.
Please note, the Nami service only accepts customer ids as strings matching the following formats:
• Numeric
• UUID
• SHA256Read about (Accounts, Login and Logout)[https://docs.namiml.com/docs/accounts-login-and-logout]
Set a CDP Identifier - link a device to a customer data platform identifier
m.namiCustomerManager.callFunc("setCustomerDataPlatformId", "PASS_THE_USERS_CDP_ID_HERE")
Updated over 1 year ago