consentmanager Android SDK API
API
Constructor
Constructor for creating a CmpManager object
Parameters
Name | Type |
Description |
context | Context |
The context of the app |
config | CMPConfig |
The configuration object for the consent manager |
closeListener | OnCloseCallback |
The callback to be invoked when the consent layer is closed |
openListener | OnOpenCallback |
The callback to be invoked when the consent layer is opened |
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 |
openCustomLayer
Opens the customized consent layer
Parameters
Name | Type |
Description |
activity | FragmentActivity |
The activity instance where the consent layer should be displayed |
containerViewId | @IdRes Int |
The ID of the container UI in which the consent layer should be displayed |
Returns
A function with no return value
Example
val activity = requireActivity()
val containerViewId = R.id.container
openCustomLayer(activity, containerViewId)
checkAndOpenConsentLayer
Check and opens the consent layer eventually.
Parameters
Name | Type |
Description |
context | Context |
The context object of the app. |
Example
val cmpManager = CmpManager()
cmpManager.checkAndOpenConsentLayer(context)
openCmpLayer
Returns if the purpose (id) has the rights to set cookies
Parameters
Name | Type |
Description |
context | Context |
The context of the app |
id | String |
The id of the purpose Attention: The purpose id is the same as shown in the purpose list and can have a prefix like C |
checkConsent | Boolean |
|
Returns
Type | Description |
Boolean | A boolean indicating whether the vendor has the consent to set cookies. |
Example
val vendorID = "1234"
val checkConsent = true
val result = hasVendorConsent(context, vendorID, checkConsent)
if (result) {
// Vendor has the rights to set cookies
} else {
// Vendor does not have the rights to set cookies
}
hasVendorConsent
Returns if the vendor (id) has the rights to set cookies
Parameters
Name | Type |
Description |
id | String: |
The id of the vendor Attention: The vendor id is the same as shown in the purpose list and can have a prefix like C |
Returns
Type | Description |
Boolean | If the purpose has the consent to set cookies |
Example
val vendorId = "S123"
consentTool.hasVendor(vendorId)
hasPurpose
Returns if the purpose (id) has the rights to set cookies
Parameters
Name | Type |
Description |
id | String: |
The id of the purpose Attention: The purpose id is the same as shown in the purpose list and can have a prefix like C |
Returns
Type | Description |
Boolean | If the purpose has the consent to set cookies |
Example
val vendorId = "S123"
consentTool.hasPurpose(vendorId)
getVendorString
Returns if the purpose (id) has the rights to set cookies
Parameters
Name | Type |
Description |
id | String: |
The id of the purpose Attention: The purpose id is the same as shown in the purpose list and can have a prefix like C |
Returns
Type | Description |
Boolean | If the purpose has the consent to set cookies |
Example
val vendorId = "S123"
consentTool.hasPurpose(vendorId)
getPurposeString
Returns the purposes String, that was set by consentmanager
Parameters
no parameters
Returns
Type | Description |
String |
The String of purposes that was set through consentmanager
|
Example
val vendorId = "S123"
consentTool.hasPurpose(vendorId)
getPurposes
Returns the purposes String, that was set by consentmanager in a List object
Parameters
Name | Type |
Description |
id | String: |
The id of the purpose Attention: The purpose id is the same as shown in the purpose list and can have a prefix like C |
Returns
Type | Description |
Boolean | If the purpose has the consent to set cookies |
Example
val vendorId = "S123"
consentTool.hasPurpose(vendorId)
Old overview (tbd)
API |
Parameters | Returns |
Description
|
openCmpConsentToolView( Context context ) |
context: The Context of the App | void | Displays a modal view with the consent web view. If the Compliance is accepted or rejected, a close function will be called. You can override this close function with your own. Therefore implement the OnCloseCallback and add this as a parameter. @apiNote User Interface -> example: Open Layer by button action |
openCmpConsentToolView( Context context, OnCloseCallback callback ) |
context: The Context of the App
callback: The OnCloseCallback that should be called when the webview is closed by action
|
void | Displays a modal view with the consent web view. If the Compliance is accepted or rejected, a close function will be called. You can override this close function with your own. Therefor implement the OnCloseCallback and give it to this function. This Method will not send a request to the consentTool Server again. It will use the last state. If you only want to open the consent Tool View again, if the server gives a response status == 1 use the checkAndProceedConsentUpdate method @apiNote User Interface -> example: Open Layer by button action |
setCloseCmpConsentToolViewListener( OnCloseCallback callback ) |
callback: The OnCloseCallback that should be called when the webview is closed by action | void | Sets a Listener. If the Compliance is accepted or rejected, this function will be called. You can override this close function with your own. Therefor implement the OnCloseCallback and add this as the parameter. |
setCustomCmpConsentToolViewAction( CustomOpenActionCallback customAction ) |
customAction: The customAction that should be called, apart from showing the consentTool | void | Sets a Custom action to a server response. |
setErrorDialogCmpConsentToolViewListener( OnErrorDialogCallback callback ) |
callback: The OnOpenCallback, that should be called, when the View will be opened. | void | Sets a Listener. If the Compliance View is opened this function will be called. You can override this open function with your own. Therefor implement the OnOpenCallback and add this as the parameter. |
setNetworkErrorExceptionListener( OnNetworkExceptionCallback callback ) |
callback: The OnErrorNetworkCallback that needs to be called. | void | Sets a listener that is called, if a network error occurs. |
setOnCMPNotOpenedCallback( OnCMPNotOpenedCallback callback ) |
callback: The cmpNotOpenedCallback action which will be called | void | Sets a action when the Consentlayer is not going to open |
setOpenCmpConsentToolViewListener( Context context, Button gdprButton ) |
context: Then Context of the App gdprButton: The Button, the openCmpConsentToolViewListener should be added to |
void | Sets a Listener to the given button, If the Button is clicked, a modal view will be displayed with the consent web view. If the Compliance is accepted or rejected, a close function will be called. You can override this close function with your own. Therefor implement the OnCloseCallback and add this as an other parameter. If the parameter is not set, but the setCloseCmpConsentToolViewListener was used to add a listener to the close event, this will be used. |
setOpenCmpConsentToolViewListener( Context context, Button gdprButton, OnCloseCallback callback ) |
context: The Context of the App gdprButton: The Button, the openCmpConsentToolViewListener should be added to
callback: The OnCloseCallback that should be called when the webview is closed by action |
void | Sets a Listener to the given button, If the Button is clicked, a modal view will be displayed with the consent web view. If the Compliance is accepted or rejected, a close function will be called. You can override this close function with your own. Therefor implement the OnCloseCallback and add this as the last parameter. |
setOpenCmpConsentToolViewListener( OnCloseCallback callback ) |
callback: The OnCloseCallback that should be called when the webview is closed by action |
void | Sets a Listener. If the Compliance View is opened this function will be called. You can override this open function with your own. Therefor implement the OnOpenCallback and add this as the parameter. |
setOpenPlaceHolderViewListener( Context context, Button button, String vendor ) |
context: The Context of the App button: A actionbutton to create the placeholderview vendor: The vendor which is assigned to the placeholder |
void | Opens the placeholder view on button click for the assigned vendor |
|
|||
calledThisDay( Context context) |
context: The Context of the App |
boolean: if the server was already contacted this day | Returns if the server was already contacted this day. |
clearAllValues(Context context) |
context: The Context of the App |
void | Resets consent data |
createPlaceholder( Context context, CMPPlaceholderParams cmpPlaceholderParams, CmpPlaceholderEventListener cmpPlaceholderEventListener) |
context: The app Context cmpPlaceholderParams: assign required placeholder parameters cmpPlaceholderEventListener: EventListener Interface for custom process functions |
CmpPlaceholder: UIView of the Placeholder | Creates a placeholder view for dynamic content blocking |
exportCMPData(Context context) |
context: The app context |
String: The consentstring | An export Function that can be called to export the full consentString generated by a ConsentWebView and saved in the Shared Preferences of this device. |
getCalledLast(Context context) |
context: The app context |
Date: Date when the server was called last | Gives information about the last date the server was contacted |
getConfig() |
|
CMPConfig: CMPConfig object |
Returns the CMPConfig which is set currently |
getGoogleACString() |
context: The app context |
String: US Privacy String of vendors that was set through consentmanager |
Returns the US Privacy String, that was set by consentmanager |
getInstance() |
|
CMPConsentTool: The initialized singleton instant of the consentmanager |
Returns the CMPConsentTool. If you have not initialised the CMPConsentTool before, The CMPConsentToolInitialisation Exception will be thrown. |
getInstanceUnsafe() |
|
CMPConsentTool: the initialised singleton Instant of the consent Manager, or null. |
Returns the CMPConsentTool, or null if it wasn't initialised. This method is unsafe, because it can lead to null pointer exceptions, but if you are sure, the ConsentTool was initialised before, you can use this Method, without the need to catch the error. We recommend to save the returned Object from the createInstant Method, to use the Methods of the consentManager. |
getLastConsentString( Context context) |
context: The app context |
String: The last set consentstring |
Returns the last given Consent, presented in base64 by consentManager |
getPurposes(Context context) |
context: The app context |
String: The String of purposes that was set through consentmanager |
Returns the purposes String, that was set by consentmanager |
getUSPrivacyString(Context context) |
context: The app context |
String: The US Privacy String of vendors that was set through consentmanager |
Returns the US Privacy String, that was set by consentmanager |
getVendorsString(Context context) |
context: The app context |
String: The String of vendors that was set through consentmanager |
Returns the Vendor String, that was set by consentmanager |
hasPurposeConsent(Context context, String id, boolean isIABPurpose) |
context: the app context id: The id of the purpose isIABPurpose: If the purpose is set by IAB standard (V1/V2) |
boolean: If the purpose has the consent to set cookies |
Returns, if the purpose (id) has the rights to set cookies. Attention: The purpose id is the same as shown in the purpose list and can have a prefix like C |
hasVendorConsent( Context context, String id, boolean isIABVendor) |
context: The app context id: The id of the vendor isIABVendor: if the vendor is set by IAB standard (V1/V2) |
boolean: If the Vendor has the Consent to set cookies. |
Returns, if the Vendor (id) has the rights to set cookies
Attention: The vendor id is the same as shown in the vendor list and can have a prefix like C, S |
importCMPData( Context context, String cmpData ) |
context: The app context cmpData: The String that will be set. The consentString should be passed as encoded base64 |
boolean: If the import was successful, or if errors occurs in the String |
An import Method that can be called to import the full consentString generated by a ConsentWebView into the Shared Preferences of this device. |
needsAcceptance(Context context) |
context: The app context |
boolean: if the user needs to give a consent |
Returns if the user needs to give a consent, cause he didn't do so in the past, or because the consent Server returned, that a new consent is required |
needsServerUpdate(Context context) |
context: The app context |
boolean: If the consentmanager needs to be updated |
If the CMPSettings need to be updated from the server, cause they were not at this day. |
|
|
|
|