Info
Content

[Android] 2. API Documentation

Constructor


Constructor for creating a CmpManager object

Parameters
Name Type

Description

context Context

The context of the app should be the FragmentActivity when using custom layout

config CmpConfig

The configuration object for the consent manager

openListener OnOpenCallback

The callback to be invoked when the consent layer is opened

closeListener OnCloseCallback

The callback to be invoked when the consent layer is closed

cmpNotOpenedCallback OnCMPNotOpenedCallback

The callback to be invoked when the consent layer could not be opened

onErrorCallback OnErrorCallback

The callback to be invoked when an error

onButtonClickedCallback
OnButtonClickedCallback

The callback to be invoked to get information about which button was pressed to close the consent layer

Example
            CmpManager.createInstance(
                context = this,
                codeId = config.id,
                serverDomain = config.domain,
                appName = config.appName,
                lang = config.language,
                closeListener = this,
                openListener = this,
                errorCallback = this,
                cmpButtonClickedCallback = this,
                cmpNotOpenedCallback = this
            )

 

initialize


The initialize function is designed to set up the CMP SDK within your application context and automatically check and open the consent layer if required. The initialize can be chained to the instance creation

Parameters
Name Type Description
context Context  
appInterface CmpLayerAppEventListenerInterface? = null  
Return

 

Example
initialize(context = ...,appInterface = ...)

 

setCallbacks


Set callbacks

Parameters
Name Type Description
openListener OnOpenCallback

The callback to be invoked when the consent layer is opened

closeListener OnCloseCallback

The callback to be invoked when the consent layer is closed

cmpNotOpenedCallback OnCMPNotOpenedCallback

The callback to be invoked when the consent layer could not be opened

onErrorCallback OnErrorCallback

The callback to be invoked when an error

onButtonClickedCallback
OnButtonClickedCallback

The callback to be invoked to get information about which button was pressed to close the consent layer

Return

No return value

Example
setCallbacks(openListener = ...,closeListener = ...,cmpNotOpenedCallback = ...,onErrorCallback = ...,onCmpButtonClickedCallback = ...)

setGoogleAnalyticsCallback


Set callback for retrieving Google Consentmode values

Parameters
Name Type Description
analyticsListener CmpGoogleAnalyticsInterface  
Return

No return value

Example
 override fun updateGoogleConsent(consentMap: Map<ConsentType, ConsentStatus>) {
     val firebaseConsentMap = consentMap.entries.associate { entry ->
         val firebaseConsentType = when (entry.key) {
             ConsentType.ANALYTICS_STORAGE -> FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE
             ConsentType.AD_STORAGE -> FirebaseAnalytics.ConsentType.AD_STORAGE
             ConsentType.AD_USER_DATA -> FirebaseAnalytics.ConsentType.AD_USER_DATA
             ConsentType.AD_PERSONALIZATION -> FirebaseAnalytics.ConsentType.AD_PERSONALIZATION
       }
         val firebaseConsentStatus = when (entry.value) {
             ConsentStatus.GRANTED -> FirebaseAnalytics.ConsentStatus.GRANTED
             ConsentStatus.DENIED -> FirebaseAnalytics.ConsentStatus.DENIED
       }
         firebaseConsentType to firebaseConsentStatus
   }
     FirebaseAnalytics.getInstance(applicationContext).setConsent(firebaseConsentMap)
 }



setGoogleAnalyticsCallback(consentModeUpdate = ...)

checkAndOpenConsentLayer


Check and open consent layer

Parameters
Name Type Description
context Context Application Context
appInterface CmpLayerAppEventListenerInterface? = null  
Return

No return value

Example
checkAndOpenConsentLayer(context = ...,appInterface = ...)

 

openCustomLayer


opens the customized consent layer

Parameters
Name Type Description
activity FragmentActivity instance
containerViewId Int  
Return

No return value

Example
openCustomLayer(activity = ...,containerViewId = ...)

 

check


Check

Parameters
Name Type Description
onCheckIsConsentRequiredCallback OnCheckIsConsentRequired fun isConsentRequired(isConsentRequired: Boolean) callback to determine if a consent is required or not
isCached Boolean = false if true the result is cached for one day
Return

No return value

Example
check(onCheckIsConsentRequiredCallback = ...,isCached = ...)

 

openCustomLayer


opens the customized consent layer

Parameters
Name Type Description
context Context Application Context
appInterface CmpLayerAppEventListenerInterface  
Return

No return value

Example
openCustomLayer(context = ...,appInterface = ...)

 

openConsentLayer


opens the consent layer

Return

No return value

Example
openConsentLayer(context)

hasConsent


check if the user gave consent

Return
Example
hasConsent()

 

enableVendorList


Enable vendor list

Parameters
Name Type Description
vendors List  
onConsentReceivedCallback OnConsentReceivedCallback? = null  
Return

No return value

Example
enableVendorList(vendors = ...,onConsentReceivedCallback = ...)

 

disableVendorList


Disable vendor list

Parameters
Name Type Description
vendors List List of vendor ids to enable.
onConsentReceivedCallback OnConsentReceivedCallback? = null  
Return

No return value

Example
disableVendorList(vendors = ...,onConsentReceivedCallback = ...)

 

enablePurposeList


Enable purpose list

Parameters
Name Type Description
purposes List List of purpose ids to enable.
updateVendor Boolean = true flag if true also enable corresponding vendors
onConsentReceivedCallback OnConsentReceivedCallback? = null  
Return

No return value

Example
enablePurposeList(purposes = ...,updateVendor = ...,onConsentReceivedCallback = ...)

 

disablePurposeList


Disable a list of purposes

Parameters
Name Type Description
purposes List List of purposes ids to disable
updateVendor Boolean = true flag if true also disable corresponding vendors
onConsentReceivedCallback OnConsentReceivedCallback? = null  
Return

No return value

Example
disablePurposeList(purposes = ...,updateVendor = ...,onConsentReceivedCallback = ...)

 

rejectAll


Reject all 

Parameters
Name Type Description
onConsentReceivedCallback OnConsentReceivedCallback? = null Callback for handling consent received event.
Return

No return value

Example
cmpManager.rejectAll {
                    // consent request done
                }

 

acceptAll


Accept all

Parameters
Name Type Description
onConsentReceivedCallback OnConsentReceivedCallback? = null Callback for handling consent received event.
Return

No return value

Example
 cmpManager.acceptAll {
                    // consent request done
                }

 

getUSPrivacyString


Get u s privacy string

Return

US Privacy String

Example
getUSPrivacyString()

 

hasVendorConsent


Has vendor consent

Parameters
Name Type Description
id String vendor id
Return
Example
hasVendorConsent(id = ...)

 

hasPurposeConsent


Has purpose consent

Parameters
Name Type Description
id String purpose id
Return

 

Example
hasPurposeConsent(id = ...)

 

getGoogleACString


Get Google AC string

Return

Google AC String

Example
getGoogleACString()

 

getConsentstring


Get last consent string

Return
Example
getConsentstring()

 

exportCmpString


Export consent string

Return

saved Cmp String

Example
exportCmpString()

 

importCmpString


Check

Parameters
Name Type Description
cmpString String cmpString to import
importCallback CmpImportCallback fun onImportResult(success: Boolean, message: String)
Return

No return value

Example
                    cmpManager?.importCmpString(
                        "..."
                    ) { _, message ->
                        coroutineScope.launch {
                            snackbarHostState.showSnackbar(
                                message = message,
                                actionLabel = "Action",
                                duration = SnackbarDuration.Short
                            )
                        }
                    }

 

getCalledLast


Get called last

Return

last called Cmp Layer Date

Example
getCalledLast()

 

calledThisDay


Called this day

Return

if layer was called today

Example
calledThisDay()

 

getAllPurposes


returns all purposes as a String

Return

purpose String

Example
getAllPurposes()

 

getAllPurposeList


returns all purposes as a List of String

Return

purpose List

Example
getAllPurposeList()

 

getEnabledPurposes


Get agreed purposes

Return

 

Example
getEnabledPurposes()

 

getEnabledPurposeList


Get agreed purpose list

Return

 

Example
getEnabledPurposeList()

 

getDisabledPurposes


Get disabled purposes

Return

 

Example
getDisabledPurposes()

 

getAllVendors


Get all vendors

Return

 

Example
getAllVendors()

 

getAllVendorsList


Get all vendors list

Return

 

Example
getAllVendorsList()

 

getEnabledVendors


Get agreed vendors

Return

 

Example
getEnabledVendors()

 

getEnabledVendorList


Get agreed vendor list

Return

 

Example
getEnabledVendorList()

 

getDisabledVendors


Get disabled vendors

Return

 

Example
getDisabledVendors()

 

needsAcceptance


Needs acceptance

Return

if user needs Acceptance

Example
needsAcceptance()
Back to top