Roku SDK: Consent Handling
Consent Status
Section titled “Consent Status”You can check the current consent status by calling:
statusEnum = SPConsentStatus()result = m.spEngine.callFunc("getConsentStatus", "YOUR_APPLICATION_ID")
if result.code = 200 status = result.data if status = statusEnum.PENDING ' Show consent banner else if status = statusEnum.COLLECTED ' Proceed normally else if status = statusEnum.RECOLLECTION_REQUIRED ' Trigger re-consent flow end ifend ifConsent Recollection Reason
Section titled “Consent Recollection Reason”When the SDK determines that consent needs to be recollected (for example, a consent update/re-consent flow), you can fetch the reason by calling:
reasonEnum = SPConsentRecollectionReason()result = m.spEngine.callFunc("getConsentRecollectionReason", "YOUR_APPLICATION_ID")
if result.code = 200 reason = result.data if reason = reasonEnum.EXPIRED ' Handle expired else if reason = reasonEnum.STRUCTURE_CHANGED ' Handle structure change end ifend ifIf no recollection reason is available, result.code will be a non-200 value (e.g., 404).
SPConsentRecollectionReason
Section titled “SPConsentRecollectionReason”| Case | Raw value | Meaning |
|---|---|---|
EXPIRED |
Expired |
Consent has expired and needs to be re-collected. |
STRUCTURE_CHANGED |
StructureChanged |
Packages and services hash mismatch. |
Enum usage guidance
Section titled “Enum usage guidance”BrightScript does not have native enum types. The SDK exposes pseudo-enums via global functions that return Associative Arrays. These are the authoritative representation for consent status and recollection reasons. The SDK guarantees these object contracts, but does not guarantee that raw string values remain stable.
Prefer these functions in your app logic:
- Use them for comparisons
- Avoid branching on raw string values
- Map to your own keys if needed
reasonEnum = SPConsentRecollectionReason()
if reason = reasonEnum.EXPIRED myReasonKey = "MY_EXPIRED"else if reason = reasonEnum.STRUCTURE_CHANGED myReasonKey = "MY_STRUCTURE_CHANGED"end ifConsent Status
Section titled “Consent Status”The SDK supports three consent states:
- Collected: Consent has already been obtained.
- Pending: Consent needs to be collected.
- RecollectionRequired: Consent needs to be re-collected.
Check If a Package Is Enabled
Section titled “Check If a Package Is Enabled”result = m.spEngine.callFunc("getPackage", "YOUR_APPLICATION_ID", "PACKAGE_ID_TO_FIND")
if result.code = 200 and result.data <> invalid if result.data.isEnabled = true ' Enable features end ifend ifThis returns a data message containing the package info. Check isEnabled to determine user consent.
Collecting Consent
Section titled “Collecting Consent”m.spEngine.payload = { scene: m.top.GetScene(), applicationId: "YOUR_APPLICATION_ID" }m.spEngine.action = "showBanner"This banner informs users about data collection and provides options to accept, deny, or customize consent.
Customization Options
Section titled “Customization Options”Users can customize their preferences via the Preference Center:
m.spEngine.payload = { scene: m.top.GetScene(), applicationId: "YOUR_APPLICATION_ID" }m.spEngine.action = "showPreferenceCenter"Essential Services
Section titled “Essential Services”You can mark certain services as essential. These cannot be disabled by users.
Privacy Policy
Section titled “Privacy Policy”The Preferences screen includes a tab showcasing content related to the app’s privacy policy.
Data Requests
Section titled “Data Requests”Users can submit data requests via the Request Data section.
