API Reference
Overview
In this article you will find all the CMP SDK public methods for Roku.
Active Methods
Get Banner Data
This method returns a JSONObject which contains all the keys required to render a banner.
m.global.OTsdk.callFunc("getBannerData")
Get Preference Center Data
This method returns a JSONObject which contains all the keys required to render a preference center.
m.global.OTsdk.callFunc("getPreferenceCenterData")
Get Vendor List Data
This method will allow your application to retrieve the JSONObject required to render the vendor list UI. It returns a JSONObject containing saved state of active vendor list.
m.global.OTsdk.callFunc("getVendorListData")
It is needed to download the preference center data at least once to get the data from getPreferenceCenterData / getVendorListData either visiting the preference center page or using the showPreferenceCenterUI public method.
Save and Log Consent
Call the saveConsent method with the interaction type to store consent locally on the device and in the OneTrust database (if the consent logging setting is enabled in your geolocation rules).
Interaction types |
---|
BANNER_ALLOW_ALL |
BANNER_REJECT_ALL |
BANNER_CLOSE |
BANNER_CONTINUE_WITHOUT_ACCEPTING |
PREFERENCE_CENTER_ALLOW_ALL |
PREFERENCE_CENTER_REJECT_ALL |
PREFERENCE_CENTER_CONFIRM |
PREFERENCE_CENTER_CLOSE |
VENDOR_LIST_ALLOW_ALL |
VENDOR_LIST_REJECT_ALL |
VENDOR_LIST_CONFIRM |
SDK_LIST_ALLOW_ALL |
SDK_LIST_REJECT_ALL |
SDK_LIST_CONFIRM |
m.global.OTsdk.callFunc("saveConsent", interactiontype)
Banner Allow All
Call this method when user selects the Allow All button on the Banner. This will opt-in the user to all category/purposes.
m.global.OTsdk.callFunc("saveConsent", ” BANNER_ALLOW_ALL”)
IAB TCF2
For IAB TCF2 templates, this method also sets the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-in. These values will be encoded into the TC String and saved to registry.
Banner Reject All
Call this method when user selects the Reject All button on the Banner. This will opt-out the user of all category/purposes.
m.global.OTsdk.callFunc("saveConsent", “BANNER_REJECT_ALL”)
IAB TCF2
For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-out. These values will be encoded into the TC String and saved to registry.
Banner Close
Call this method when closing the Banner. It will save the default consent values for each category/purpose based on the geolocation rule.
m.global.OTsdk.callFunc("saveConsent", “BANNER_CLOSE”)
IAB TCF2
For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any). These values will be encoded into the TC String and saved to registry.
Preference Center Allow All
Call this method when user selects the Allow All button on the Banner. This will opt-in the user to all category/purposes.
m.global.OTsdk.callFunc("saveConsent", “PREFERENCE_CENTER_ALLOW_ALL”)
IAB TCF2
For IAB TCF2 templates, this method also sets the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-in. These values will be encoded into the TC String and saved to registry.
Preference Center Reject All
Call this method when user selects the Reject All button on the Banner. This will opt-out the user of all category/purposes.
m.global.OTsdk.callFunc("saveConsent", “PREFERENCE_CENTER_REJECT_ALL”)
IAB TCF2
For IAB TCF2 templates, this method also updates the values of IAB Purposes, Legitimate Interests (if any), Special Features (if any), Vendor Purpose Consent, and Vendor Purpose Legitimate Interest (if any) to opt-out. These values will be encoded into the TC String and saved to registry.
Programmatically Update and Save Purpose Consent
These methods are typically utilized in a BYOUI approach and can be used to update and save consent programmatically for a specific category to true
or false
based on user input. Simply pass in the group/category ID and consent status to update the values.
Usage
Modifying the user's consent is a two step approach. updatePurposeConsent() is used to set the state of the consent settings on the UI and saveConsent() is used to commit and save the consent to local storage.
saveConsent must be called or consent will not be committed and changed.
m.global.OTsdk.callFunc("updatePurposeConsent", "C0004",false)
Brightscript
m.global.OTsdk.callFunc("saveConsent", “PREFERENCE_CENTER_REJECT_ALL”)
Parameters
forGroup
: Category/Group ID of the category to be modified (e.g. C0001, C0002, C0004, etc.)consentValue
: Consent status given by the user for a category/group. Boolean type.updateHierarchy
: This field is optional. Set totrue
if you have child categories that need to be updated with the parent.OTConsentInteractionType
: Denotes the type of interaction used to commit/save consent (e.g. banner allow all, preference center confirm, preference center reject, etc.)
Sample implementation on how to update and save, if you have multiple categories to update at a time.
m.global.OTsdk.callFunc("updatePurposeConsent", "C0004", true);
m.global.OTsdk.callFunc("updatePurposeConsent", "C0005", true);
m.global.OTsdk.callFunc("updatePurposeConsent", "C0006", true);
m.global.OTsdk.callFunc("updatePurposeConsent", "IABV2_6", true);
m.global.OTsdk.callFunc("saveConsent", “PREFERENCE_CENTER_REJECT_ALL”)
Get Vendor Consent
This method returns the consent value for a specific vendor.
The OTVendorListMode
is one of IAB or Google depending on the type of vendor list being referenced. The second argument is the ID of the vendor as a string.
IAB Vendor
// example for getting IAB vendor consent value
m.global.OTsdk.callFunc("getConsentStatusForVendorId", "iab", "8")
Google Vendor
// example for getting Google vendor consent value
m.global.OTsdk.callFunc("getConsentStatusForVendorId", "google", "8")
Parameters
vendorType
(OTVendorListMode)vendorId
(string)
Get Total Vendor Count
This method allows you to return the total number of vendors your app is using. This can be useful in instances where you're building your own banner and need to include the vendor count as required by IAB.
vendorCount = 0
vendorData = m.global.OTsdk.callFunc("getVendorListData")
if vendorData <> invalid and vendorData .iab2V2Vendors <> invalid and vendorData.iab2V2Vendors.vendors <> invalid then vendorCount = vendorData.iab2V2Vendors.vendors.count()
print vendorCount
Query Consent Status for a Category
Query the current consent status for any of the categories included in your application. This can be used to determine what privacy action is needed at app launch or anytime the consent status is needed without being notified by an event broadcast. Simply pass in the Category ID (eg. C0001) and the method will return the current consent status.
m.global.OTsdk.callFunc("getConsentStatusForGroupID", "C0002")
Parameters
CustomGroupId
: Custom group ID contained in the group .json object returned by SDK public methods. Custom group IDs for each category can be obtained from the OneTrust console as well.
Return Values
1
= Consent is given (An end user interacts with the SDK and gives consent)0
= Consent is not given (An end user interacts and does not give consent)-1
= Consent has not been collected (The SDK is not yet initialized for the end user)
Query Consent Status for a Specific SDK
Query the current consent status for any of the SDKs included in your application. This can be used to determine what privacy action is needed at app launch or anytime the consent status is needed without being notified by an event broadcast. Simply pass in the SDK ID and the method will return the current consent status.
m.global.OTsdk.callFunc("getConsentStatusForSDKId", "018dcc15-9f1b-7329-88bc-db0d09d28eb4")
Parameters
SDK GUID
: SDK ID contained in the group .json object returned by SDK public methods. SDK IDs for each SDK configured in the application can be obtained from the OneTrust console as well.
Return Values
1
= Consent is given (An end user interacts with the SDK and gives consent)0
= Consent is not given (An end user interacts and does not give consent)-1
= Consent has not been collected (The SDK is not yet initialized for the end user)
Should Show Banner
This method will inform your application if the OneTrust Banner has to be presented to the user or not for the user's current location. This method will return true or false based on the geolocation configurations you have assigned for the application in the OneTrust environment. This can be used by your app to determine if functions to build and display UI have to be called.
m.global.OTsdk.callFunc("shouldShowBanner")
Return Values
true
= show banner for that geolocation.false
= don't show banner for user's geolocation / consent has been taken already.
Clear SDK Data
This method will delete all the data saved in the SDK. When the application calls this method, SDK will:
- Clear all values saved in registry.
m.global.OTsdk.callFunc("clearOTSDK")
Multi Profile Consent
This feature allows you to store multiple consents on the device if you allow multiple user profiles to use one login. View more information here:
For more information, see Multi Profile Consent.
Deprecated Methods
showVendorListUI ()
Method | showVendorListUI() |
---|---|
Description | onetrust sdk internally uses this method to show the vendor list Ui. |
Reason | Showing vendor list ui will be handled from banner/preference center ui methods |
Deprecated Version | 202503.2.0 |
Migrate To | Applications do not need to migrate |
onHideBanner(), onShowBanner(), onBannerClickedAcceptAll(), onBannerClickedRejectAll(), onHidePreferenceCenter(), onPreferenceCenterRejectAll(), onPreferenceCenterAcceptAll(), onPreferenceCenterConfirmChoices()
Method | onHideBanner(), onShowBanner(), onBannerClickedAcceptAll(), onBannerClickedRejectAll(), onHidePreferenceCenter(), onPreferenceCenterRejectAll(), onPreferenceCenterAcceptAll(), onPreferenceCenterConfirmChoices() |
---|---|
Description | Method connected with the UI Interaction Events for banner/preference center. |
Reason | We are shifting to a more flexible approach using m.global.OTsdk.eventlistener.observeField("onShowBanner"..) . This gives more flexibility for capturing advanced analytics in the future. |
Deprecated Version | 202503.2.0 |
Migrate To | Applications need to migrate. See below. |
m.global.OTsdk.eventlistener.observeField("onShowBanner", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHideBanner", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onBannerClickedAcceptAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onBannerClickedRejectAll", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onHidePreferenceCenter", "eventlistener")
m.global.OTsdk.eventlistener.observeField("onPreferenceCenterAcceptAll", "eventlistener") m.global.OTsdk.eventlistener.observeField("onPreferenceCenterRejectAll", "eventlistener") m.global.OTsdk.eventlistener.observeField("onPreferenceCenterConfirmChoices", "eventlistener
setsaveGroupqueue()
Method | setsaveGroupqueue() |
---|---|
Description | onetrust sdk internally uses this method to save consent data to the local . |
Reason | This will be automatically updated when required. |
Deprecated Version | 202503.2.0 |
Migrate To | No need to migrate |
updateSdkListConsentData()
Method | updateSdkListConsentData() |
---|---|
Description | onetrust sdk internally uses this method used to update sdk list consent data. |
Reason | This will be automatically updated when required. |
Deprecated Version | 202503.2.0 |
Migrate To | No need to migrate |
updateVendorPurposeConsent()
Method | updateVendorPurposeConsent |
---|---|
Description | This method will allow your application to update consent value for vendors. Applications will have to pass a valid String value vendor ID along with a boolean state. |
Reason | We are shifting to a more flexible approach using updateVendorConsent . |
Deprecated Version | 202503.2.0 |
Migrate To | Applications should migrate. See below. |
m.global.OTsdk.callFunc("updateVendorConsent", "92", true)
initOTSDKData()
Method | initOTSDKData() |
---|---|
Description | The way the SDK initializes. |
Reason | We are shifting to a more flexible approach using startSDK. |
Deprecated Version | 202503.2.0 |
Migrate To | Applications should migrate to using startSDK(). See below. |
m.global.OTsdk.callFunc("startSDK", sdkParams)
setBannerLogoSize() and setPreferenceCenterLogoSize()
Method | setBannerLogoSize() and setPreferenceCenterLogoSize() |
---|---|
Description | Allows banner/preference center logo to set the size. |
Reason | Logo size will adjust automatically when we load banner/preference center |
Deprecated Version | 202503.2.0 |
Migrate To | not required |
optIntoSaleofData() and optOutOfSaleOfData()
Method | optIntoSaleOfData() and optOutOfSaleOfData() |
---|---|
Description | Update the US Privacy String to indicate the user has opted-out/opted-in of the sale of personal information |
Reason | - |
Deprecated Version | 202503.2.0 |
Migrate To | not required |
Set Data Subject Identifier
This method sets the identifier
for the user profile the consent is being saved to.
- When the
identifier
is not set, the SDK will generate a unique (anonymous) identifier by default. - If an empty
identifier
is passed, OneTrust will remove the last saved identifier.
Method | m.global.OTsdk.callFunc("setDataSubjectIdentifier",{"subjectIdentifier":”user id” }) |
---|---|
Requires SDK Init? | Yes |
Arguments | subjectIdentifier: string |
Migrate To | 202503.2.0 |
Updated Events and Public Methods
- The initOTSDKData public method has been deprecated and replaced with startSDK(). The startSDK() method must be called at least once per instance to download the required data. Refer to the startSDK public method for more details.
- All observables have been consolidated into a single observable node “eventlistener”, which now contains all SDK events. Refer to the Events section for details.
- consentResponse has been renamed to OTConsentUpdated.
- onSdkBroadCast has been renamed to allSDKViewsDismissed.
- onHideFailure is now part of the onDataSuccess observer and provides failure data for all failure cases.
m.global.OTsdk.eventlistener.observeField("dataDownloadSuccess", "eventlistener")
- Consent-related public methods now require two parameters (
id
andvalue
) instead of passing data as an object.
m.global.OTsdk.callFunc("updatePurposeConsent", "IAB2V2_2", true)
- The saveConsent public method now requires a single parameter,
interactionType
. Refer to the public method section for more details on interaction types.
m.global.OTsdk.callFunc("saveConsent", "PREFERENCE_CENTER_CONFIRM")
Updated 4 days ago