Skip to content

Advanced Usage

Use onConsentChange() to receive a normalized snapshot after each consent submission.

Even when snapshot.status is COLLECTED, individual plugin block decisions must be evaluated separately — consent may have been granted at the category level but a specific plugin within that category could still be blocked. Use snapshot.categories (the same structure as getConsentedCategories()) alongside api.resolvePluginBlockedStatus() to determine the correct action for each plugin.

var unsubscribe = api.onConsentChange(function (snapshot) {
if (snapshot.status === api.ConsentStatus.COLLECTED) {
// Overall consent collected — evaluate each plugin's block status
// from the snapshot's category structure before enabling features.
var analyticsBlocked = api.resolvePluginBlockedStatus("Google Analytics");
if (analyticsBlocked === false) {
enableAnalytics();
} else {
disableAnalytics();
}
}
renderConsentState(snapshot);
});
// Remove listener on teardown
unsubscribe();

Snapshot fields:

  • status: consent lifecycle value (api.ConsentStatus.*)
  • categories: category and plugin snapshot — same structure as getConsentedCategories(), or null
  • localClientId: device-scoped client ID or null
  • isExpired: expiry flag
  • expiry: Date or null
EventFired onDetailWhen
sp:sdk-readywindow{ sp, api }Core SDK initialized and SPTizenAPI ready
sp:tv-mode-enabledwindow{ tv: true, forced: boolean }TV environment detected before Core SDK load. forced is true when detection was bypassed via SPTizenConfig.forceTVMode
window.addEventListener("sp:sdk-ready", function (event) {
var api = event.detail.api;
mountConsentUi(api);
});

Secure Privacy Tizen SDK generates a unique client ID for the device. Retrieve it using:

const clientId = api.getClientId();

This clientId can be used to associate the user’s consent with internal identifiers in your app or backend systems.

Returns the two-letter ISO 3166-1 alpha-2 country code detected by the SDK for this device, or null if it has not been resolved yet.

const countryCode = api.getCountryCode();
// → 'IN' | 'US' | 'DE' | null

The country code reflects the geographic location resolved at the time consent was first collected. The CMP uses it to determine which regional privacy regulation applies (for example, GDPR for EU countries).