SDK Integration
How to setup the Roku Nami SDK
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" />
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.
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.
Set a CDP Identifier - link a device to a customer data platform identifier
m.namiCustomerManager.callFunc("setCustomerDataPlatformId", "PASS_THE_USERS_CDP_ID_HERE")
Last updated