Setup and Initialisation
Overview
Section titled “Overview”The Secure Privacy Tizen TV SDK enables consent management for Tizen-based smart TV applications. It helps your app stay compliant with privacy regulations while giving viewers full control over their data preferences — with a built-in consent banner and preference centre optimised for TV remote navigation.
Getting Started
Section titled “Getting Started”Obtain Your Secure Privacy Script
Section titled “Obtain Your Secure Privacy Script”To use the Secure Privacy Tizen TV SDK, you need your Secure Privacy scripts.
- Sign in to your account at cmp.secureprivacy.ai.
- Navigate to the Installation page.
- Copy your Secure Privacy script tags.
Installation
Section titled “Installation”Add scripts to your page
Section titled “Add scripts to your page”Paste the Tizen wrapper script first, then your Secure Privacy script, both at the top of the <head> section of your index.html.
<head> <!-- 1) Secure Privacy Tizen TV wrapper — must come before the Core SDK --> <script src="https://tv.secureprivacy.ai/sp-tizen-wrapper.min.js"></script>
<!-- 2) Your Secure Privacy script (copied from your account's Installation page) --> <script src="https://app.secureprivacy.ai/script/YOUR_SCRIPT_ID.js"></script></head>[Experimental] Running on a TV with a custom user-agent
Section titled “[Experimental] Running on a TV with a custom user-agent”If your device reports a non-standard user-agent that does not contain Tizen, SmartTV, or WebTV, the wrapper’s auto-detection will fail silently and window.SPTizen will never be set.
To bypass the check, declare window.SPTizenConfig with forceTVMode: true in an inline <script> tag that appears before the wrapper script:
<head> <!-- 1) Optional: bypass UA detection for custom TV environments --> <script>window.SPTizenConfig = { forceTVMode: true };</script>
<!-- 2) Secure Privacy Tizen TV wrapper — must come before the Core SDK --> <script src="https://tv.secureprivacy.ai/sp-tizen-wrapper.min.js"></script>
<!-- 3) Your Secure Privacy script --> <script src="https://app.secureprivacy.ai/script/YOUR_SCRIPT_ID.js"></script></head>When forceTVMode is active the wrapper behaves identically to a successful auto-detection: TV-mode styles and D-pad handling are injected, window.SPTizen is set, and sp:sdk-ready fires normally. The sp:tv-mode-enabled event will include forced: true in its detail so you can distinguish the two paths.
Initialisation
Section titled “Initialisation”Wait for SDK readiness
Section titled “Wait for SDK readiness”Call window.SPTizen methods only after sp:sdk-ready.
window.addEventListener("sp:sdk-ready", function (event) { var api = event.detail.api; initApp(api);});Fast-path if already ready
Section titled “Fast-path if already ready”If the SDK has already fired before your listener is registered, use the fast-path pattern:
if (window.SPTizen) { initApp(window.SPTizen);} else { window.addEventListener( "sp:sdk-ready", function (event) { initApp(event.detail.api); }, { once: true }, );}Timeout Diagnostics
Section titled “Timeout Diagnostics”Use window.__sp_tizen_initialized__ to distinguish wrapper load failures from delayed SDK initialization.
var TIMEOUT_MS = 12000;
var timeoutId = window.setTimeout(function () { if (!window.__sp_tizen_initialized__) { showError("Tizen wrapper script did not load. Verify the CDN script tag is reachable."); return; }
showError("SDK not ready yet. Check TV user-agent and network access.");}, TIMEOUT_MS);
window.addEventListener( "sp:sdk-ready", function () { clearTimeout(timeoutId); }, { once: true },);