Info
Content

[Unity] 2. API Documentation

AddEventListeners

Sets Android-specific callbacks for CMP events.

Example
_cmpManager.AddEventListeners(OnOpen, OnClose, OnNotOpened, OnCmpButtonClicked, OnError);

CheckConsentIsRequired

Checks if user's consent is required and, if so, opens the consent layer UI. This method consumes one pageview. 

Parameters
None.
Return

TRUE if the user's consent is required

FALSE otherwise.

Example
var isRequired = await _cmpManager.CheckConsentIsRequired();

CmpUIConfig Overview

Property/Method Description Type/Parameters
screenConfig Property to hold the chosen screen configuration. ScreenConfig enum
androidUiType (Android only) UI Type for Android devices. AndroidUiType enum
androidFragmentContainerId (Android only) Container ID for Android Fragment. int
isFocusable (Android only) If the UI should be focusable. bool
isOutsideTouchable (Android only) If the outside touch should be detected. bool
SetAndroidFragmentContainerId (Android only) Sets the container ID for the Android fragment. id (int)
SetAndroidUiType (Android only) Sets the UI type for Android. type (AndroidUiType)
CmpBridgeSetConsentManagerModalPresentationStyle (iOS only) Sets the modal presentation style via external call. modalPresentationStyle (int)
ConfigureModalPresentationStyle (iOS only) Configures the modal presentation style for iOS. style (CmpIOSModalPresentationStyle)

CmpConfig Overview

Property/Method Description Type/Parameters
Constructor Initializes the CMP configuration with the necessary parameters. id, domain, appName, language, uiConfig (optional)
UIConfig Property to hold the UI configuration. CmpUIConfig
IdfaOrGaid Identifier for Advertisers or Google Advertising ID. string
Timeout Timeout for CMP operations. int
JumpToSettingsPage Whether to jump to the settings page automatically. bool
DesignId Optional design ID for CMP UI customization. int?
Debug Enables debug mode. bool
Id The unique identifier for the CMP instance. string (readonly)
Domain The domain associated with the CMP instance. string (readonly)
AppName The name of the application using CMP. string (readonly)
Language The language for CMP UI and operations. string (readonly)

ExportCmpString

Parameters
None.
Return

String: The exported CMP settings as a string.

Example
string cmpSettings = ExportCmpString();

GetAllPurposes

Returns all purposes' IDs. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of purpose IDs.

Example
List<string> purposes = GetAllPurposes();

GetAllVendors

Returns all vendors' IDs for a given CMP. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of vendor IDs.

Example
List<string> allVendors = GetAllVendors();

GetDisabledPurposes

Returns all disabled purposes' IDs for a given CMP. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of disabled purpose IDs.

Example
List<string> disabledPurposes = GetDisabledPurposes();

 

GetDisabledVendors

Returns all disabled vendors' IDs for a given CMP. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of disabled vendor IDs.

Example
List<string> disabledVendors = GetDisabledVendors();

GetEnabledPurposes

Returns all enabled purposes' IDs for a given CMP. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of enabled purpose IDs.

Example
List<string> enabledPurposes = GetEnabledPurposes();

GetEnabledVendors

Returns all enabled vendors' IDs for a given CMP. This method consumes no pageviews. 

Parameters
None.
Return

List<string>: A list of enabled vendor IDs.

Example
List<string> enabledVendors = GetEnabledVendors();

GetGoogleAcString

Retrieves the Google additional consent ID ('addtlConsent') string that was set by the consent manager.

For further information, check the Google Additional Consent technical specification.  

This method consumes no pageviews. 

Parameters
None
Return

string: The Google Advertiser Consent string.

Example
string googleAcString = GetGoogleAcString();

GetUsPrivacyString

Retrieves the US Privacy String. This U.S. privacy string is a cookie that stores information about disclosures made and choices selected by the website visitor regarding their consumer rights. This method consumes no pageviews. 

Parameters
None.
Return

string: The US Privacy string.

Example
string usPrivacyString = GetUsPrivacyString();

HasConsent

Checks if the user already provided his consent. The consent layer can have the option to just close the layer. In that case, the user did not provided a consent. This method consumes no pageviews. 

Parameters
None.
Return

TRUE if user has given consent

FALSE otherwise

Example
var hasConsent = _cmpManager.HasConsent();

HasPurpose

Checks if the purpose ID is enabled based on the user consent. This method consumes no pageviews. 

Parameters
  • id: The ID of the purpose to check.
Return

TRUE if the purpose is selected

FALSE otherwise.

Example
bool result = _cmpManager.HasPurpose(purposeId);

HasVendor

Checks if the vendor ID is enabled based on the user consent. This method consumes no pageviews. 

Parameters
Name Type Description
id string The ID of the vendor to check. You can find the vendor IDs in your account under Menu > CMPs > Vendors.
Return

TRUE if the vendor is selected

FALSE otherwise.

Example
bool result = HasVendor("vendorId");

ImportCmpString

Parameters

string: The CMP string

Return

CmpImportResult: Result if the import was successful.

Example
 result = await _cmpManager.ImportCmpString(cmpString);

Initialize

Initialize function will initialize the consent layer and checks automatically if the user needs a consent or not. This function will eventually open the consent layer and Will interact wit the Apple Tracking Transparency API to ask the user for Consent. This method consumes one pageview.

Parameters
Name Type Description
domain String The domain of the Consent Management Platform.
codeId String The code ID for the application.
appName String The name of the application.
language String The language code (e.g., "EN", "DE") for localization.
Example
       private void Awake()
        {
            _cmpManager = CmpManager.Instance;
        }

        private void Start()
        {
            _mainThread = Thread.CurrentThread;
            Debug.Log("Consentmanager SampleScene started");

#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
            var config = new CmpConfig(CodeId, Domain, AppName, Language);
            // Example of using a custom layout 
            // var customRect = new Rect(0,0, 300, 600);
            // config.SetCustomLayout(customRect);

            // alternative create the instance directly with the required parameters
            // _cmpManager.Initialize(Domain, CodeId, AppName, Language); 

            _cmpManager.Initialize(config);
            _cmpManager.Launch();
#endif
        }

Launch (deprecated)

 Launches the CmpManager and shows the Consent Layer if needed.

Example
_cmpManager.Launch();

OpenConsentLayer

Forcefully opens the CMP consent layer webview. This method consumes one pageview.

Parameters
None.

 

Return
None.
Example
_cmpManager.OpenConsentLayer();

 

OpenConsentLayerOnCheck

Checks if user's consent is required and, if so, opens the consent layer webview. This method consumes one pageview. 

Parameters
None.

 

Return
None.
Example
_cmpManager.OpenConsentLayerOnCheck();

 

Back to top