How to use it?


How to use appConsent object?

Here is a list of the most commonly used methods

appConsent.consentGiven()

Return true if consent is given, false otherwise.

triangle-exclamation

When the user has completed the consent process and given their consent, this "callback" informs them of this.

circle-info

INFO

It is recommended to define it before trying to display the CMP and to remove it once consent has been given or the cmp has not been displayed.

appConsent.setOnPresentNoticeListener(object : OnPresentNoticeListener { 
    override fun presentConsentGiven() {
        // ...
    }

    override fun presentConsentError(error: Throwable?) {
        // ...
    }
})

Remove Listener

Try to Display CMP notice

There are 2 display modes:

  1. The first runs only if user consent is required.

  2. The second, which should be used to allow your users to consult/modify their consent (often used from your settings screen to display your user's privacy policy)

circle-info

INFO

By default this method tries to display the CMP. It tries because, depending on the region of your users (if no settings are made via ACConfiguration to force the display) then it will follow its controls and display the CMP only if necessary.

It will also be displayed if the user consent has not yet been given or if it needs to be renewed.

It returns true if the CMP is displayed, false otherwise

circle-info

INFO

These same methods also exist without the context parameter.

These methods do the same thing, except that they implement the FLAG_ACTIVITY_NEW_TASK flag to be called from a context other than an activity.

GCM Status

circle-info

INFO

This method shows the current status of GCMv2 (Google Consent Mode V2).

Before calling up this method, it's best to make sure that the user has already given his consent and that it's up to date, and that the CMP doesn't need to be redisplayed.

Otherwise :

  • either the saved value of the old consent will be returned

  • or the default values of your FirebaseAnalytics AndroidManifest configuration will be returned

Set the default consent state from google documentationarrow-up-right

Return GCMStatus

Check for update

This method allows you to check from our servers whether your Notice has been updated since it was last displayed on your user's device.

circle-info

INFO

The method will return true if you have modified the Source and/or Notice from your dashboard and, if and only if, you have configured your Notice to update for all your users.

triangle-exclamation

Using AppConsent's more specific methods

Here's a list of methods that could be useful if you want to go further in tracking user consent.

Consentable allowed

Return true if consentable with id = 1 and consentableType = 0 is allowed, false otherwise. The id to pass is the iabId of your purpose and the consentableType is the type, e.g: purpose = 0 .

Stack Allowed

Return true if stack with id = 1 is allowed, false otherwise.

Vendor allowed

Return true if vendor with id = 1 is allowed, false otherwise.

All Consentables Allowed

Returns true if all consentables have been allowed false if at least one consentable is not allowed and null if no choice has yet been made (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

All Consentables Disallowed

Returns true if all consentables have been disallowed false if at least one consentable is not disallowed and null if no choice has yet been made (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

All Stacks Allowed

Returns true if all stacks have been accepted false if at least one stack is not accepted and null if no choice has yet been made or not present into your notice (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

All Stacks Disallowed

Returns true if all stacks have been disallowed false if at least one stack is not disallowed and null if no choice has yet been made or not present into your notice (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

All Vendors Allowed

Returns true if all vendors have been allowed false if at least one vendor is not allowed and null if no choice has yet been made (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

All Vendors Disallowed

Returns true if all vendors have been disallowed false if at least one vendor is not disallowed and null if no choice has yet been made (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

User Accept All

Returns true if all consent items, stacks and vendors are allowed. false if at least one of them is not allowed and null if no data is present yet (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

User Deny All

Returns true if all consent items, stacks and vendors are disallowed. false if at least one of them is not disallowed and null if no data is present yet (notice not yet downloaded, choice not yet made, application cache deleted, etc.).

Set consentable status

Set consentables status, save it and send it to server.

Clear consents

Locally removes user consent, but not on the server (this will allow a new display of the CMP on the next call to tryToDisplayNotice(false) for example)

Set external ids

Allows to define additional Ids that will be taken into account when validating user consent.

Get external ids

Retrieves your previously registered external ids

(Bonus) Retrieve your consents

Your consents are saved in SharedPreferences of your application. To know more about keys used to save your consents, please refer to the IAB documentationarrow-up-right.

We also provide an additional key for Google Additionnal Consent IABTCF_AddtlConsent returning a String.

Last updated