QR CMP: Methods

QR CMP: Methods

UI Methods


The script globally adds the SibboCMP object. This object includes the following methods:

init


Loads all configurations and checks if the interface needs to be displayed:

Example with HTTPS protocol:

  1. SibboCMP.init(configuration, boolean, boolean); 

Example with HTTP protocol:

  1. SibboCMP.init(configuration, boolean, boolean, configuration 2); 

openBanner


Display the initial CMP banner.

  1. SibboCMP.openBanner(true);

openBannerIfNoTCS


Display the initial CMP banner when using the bannerHidden configuration property: true if there is no consent string saved in local storage or cookies.
  1. SibboCMP.openBannerIfNoTCS();

isOpen


Returns true if CMP is visible, and false if not.
  1. SibboCMP.isOpen();


initialBannerHasToRefloatCheck

Returns true if CMP needs to redisplay the initial banner, and false if not. This is used when the bannerHidden configuration property is true, in conjunction with the methods open/openBanner/openBannerIfNoTCS.

  1. SibboCMP.initialBannerHasToRefloatCheck();

close

Hides the CMP interface:
  1. SibboCMP.close();  

sendKeyPressEvent

Method to send from the client the keydown event to the CMP, used with customKeydown property in configuration. This method can be used when there are conflicts between the keydown listeners of the device and the CMP.
With the property customKeydown: true, the CMP will not listen to keydown event and receive it from the application with this method.
  1. SibboCMP.sendKeyPressEvent(event);  
All methods except SibboCMP.init can only be used after the CMP has been initialized correctly.


Methods to obtain consent

To obtain consents, we use the method __tcfapi with various commands such as 'addEventListener', 'getInAppTCData', and 'getOtherVendorConsents' as we'll see below. The old command 'getTCData' is obsolete and should be replaced with 'addEventListener' to obtain the consent string.

To obtain the user's consent string, you need to call the addEventListener command:

The CMP runs on a TV device, ES6 JavaScript features like arrow functions, const, let, etc., cannot be used. ES5 must be used instead.

  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                         

  2.   if(success) {

  3.     var consent = tcData.tcString;
  4.     console.log(consent);

  5.   } else {
  6.     // do something else

  7.   }

  8. });

To obtain consent for vendors not included in IAB, you need to call the command getOtherVendorConsents:

The CMP runs on a TV device, so ES6 JavaScript features like arrow functions, const, let, etc., cannot be used. ES5 must be used instead.

To obtain consents from all vendors not included in IAB:

  1. __tcfapi("getOtherVendorConsents", 2, function(otherVendorConsents, success) {                                                   
  2.   if (success) {
  3.     console.log(otherVendorConsents);
  4.   } else {
  5.     console.error('Error: could not get otherVendorConsents')
  6.   }
  7. });

To obtain consent for a specific vendor not included in IAB, you need to use the cookieName property in the configuration to identify it. For example, for the vendor Cynapsis Interactive GmbH, its cookieName is cynapsisConsent:

  1. __tcfapi("getOtherVendorConsents", 2, function(otherVendorConsents, success) {                                                   
  2.   if (success) {
  3.     var cynapsis = otherVendorConsents.cynapsisConsent;
  4.     console.log(cynapsis);
  5.   } else {
  6.     console.error('Error: could not get otherVendorConsents')
  7.   }
  8. });

Obtaining consents examples

All the information generated by the CMP is stored in the tcData object of the addEventListener function. Below are some examples of the type of information that can be obtained:

To get the consent of a purpose (e.g. purpose with ID 10):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                      

  2.   if(success) {

  3.     var consent = tcData.purpose.consents[10];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a purpose based on legitimate interest (e.g. purpose with ID 10):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                      

  2.   if(success) {

  3.     var consent = tcData.purpose.legitimateInterests[10];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a vendor's purpose (e.g. vendor with ID 565):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                     

  2.   if(success) {

  3.     var consent = tcData.vendor.consents[565];
  4.     console.log(consent);

  5.  }

  6. });


To get the consent of a vendor's purpose based on legitimate interest (e.g. vendor with ID 565):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.vendor.legitimateInterests[565];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a publisher's purpose (e.g. publisher's purpose with ID 10):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.publisher.consents[10];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a publisher's purpose based on legitimate interest (e.g. publisher's purpose based on legitimate interest with ID 10):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.publisher.legitimateInterests[10];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a publisher's custom purpose (e.g. publisher's custom purpose with ID 1):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.publisher.customPurpose.consents[1];
  4.     console.log(consent);

  5.   }

  6. });


To get the consent of a publisher's custom purpose based on legitimate interest (e.g. publisher's custom purpose based on legitimate interest with ID 1):
The CMP is running on a TV device, you cannot use javascript ES6: arrow functions, const, let, etc. You must use javascript ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.publisher.customPurpose.legitimateInterests[1];
  4.     console.log(consent);

  5.   }

  6. });

To get the consent of a special feature (e.g. special feature with ID 1):
El CMP se ejecuta en un dispositivo de TV, no se puede usar javascript ES6: funciones flecha, const, let, etc. Se debe usar ES5.
  1. __tcfapi('addEventListener', 2, function(tcData, success) {                                                                                                    

  2.   if(success) {

  3.     var consent = tcData.specialFeatureOptins[1];
  4.     console.log(consent);

  5.   }

  6. });