Skip to main content

Initialization and Release

Content Security Policy (CSP) Notice
If your website enforces a Content-Security-Policy (CSP) via HTTP headers or <meta http-equiv="Content-Security-Policy"> , you must explicitly allow the following domains in your policy configuration. These domains are required for proper SDK operation.

DirectiveDomainPurpose
script-srchttps://*.anypoint.tvFlower SDK (flower-sdk-X.X.X.js) loading
script-srchttps://imasdk.googleapis.comGoogle PAL SDK (pal.js) loading
img-srcreds-tr.anypoint.tvAd tracking and reporting

For example, you may need to include the following directives:

script-src https://*.anypoint.tv https://imasdk.googleapis.com;
img-src reds-tr.anypoint.tv;

About the Google PAL SDK requirement

The Flower SDK loads the Google PAL (Programmatic Access Library) SDK from https://imasdk.googleapis.com/pal/sdkloader/pal.js to generate the nonce required for ad requests. If imasdk.googleapis.com is not allowed under script-src, you will see a console error like the following and ads will not be served correctly:

Loading the script 'https://imasdk.googleapis.com/pal/sdkloader/pal.js' violates the following Content Security Policy directive: "script-src 'self' ...". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. The action has been blocked.

Because script-src-elem falls back to script-src when script-src-elem is not explicitly set, adding https://imasdk.googleapis.com to script-src (or to script-src-elem if you define it) resolves this error.

Before using any features of the SDK, you must initialize it in your OTT app's startup process. Set the operating environment mode to either local, dev, or prod as described below.

  • local: This mode can be used in a local environment and the default log level is Verbose.
  • dev: This mode can be used in a development environment and in this mode, the error log that is generated in the SDK is saved in the server. The default log level is Info.
  • prod: This mode can be used in a commercial environment and in this mode, the error log that is generated in the SDK is saved in the server. The default log level is Warn. In HTML5 environments, you do not need to explicitly call a release function when your OTT app terminates.

Single HTML File

<html>
<head>
<!-- Flower SDK -->
<script src="https://sdk.anypoint.tv/html5/flower-sdk-1.0.0.js"></script>
...
<!-- Another library files -->
<script src="https://.../.js"></script>
<script type="text/javascript">
// TODO GUIDE: initialize SDK
  FlowerSdk.setEnv("local")
      FlowerSdk.init()
</script>
</head>
...
</html>

React

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

// TODO GUIDE: initialize SDK
// env must be one of local, dev, prod
window.FlowerSdk.setEnv('local');
window.FlowerSdk.init();
// Log level must be one of Verbose, Debug, Info, Warn, Error, Off
window.FlowerSdk.setLogLevel('Verbose');