ConsentManager
Reference guide for ConsentManager class and methods provided by Tealium for Android (Kotlin).
Class: ConsentManager
The following summarizes the commonly used methods of the ConsentManager
class for Kotlin. See Consent Management for more details.
Method | Description |
---|---|
isConsentLoggingEnabled |
Gets/sets whether to log consent preference changes |
policy |
Gets the current policy that is in force (nullable) |
reset() |
Resets the Consent Status and Categories back to default values |
userConsentCategories |
Gets/sets the currently consented set of ConsentCategory s |
userConsentStatus |
Gets/sets the current user ConsentStatus |
isConsentLoggingEnabled
Get or set whether to log changes to the user consent preferences. Initialized via the TealiumConfig.consentManagerLoggingEnabled option.
tealium.consentManager.isConsentLoggingEnabled // e.g. false
policy
Returns the currently in-use ConsentPolicy
. Initialized via the TealiumConfig.consentManagerPolicy option, and may be set to null
.
val policy = tealium.consentManager.policy // e.g. ConsentPolicy.GDPR
reset()
Returns the provided userConsentStatus
and userConsentCategories
back to their default values; ConsentStatus.UNKNOWN
and null
respectively.
tealium.consentManager.reset()
userConsentCategories
Set or get the current Consent Status as granted by the app user. Learn more about the available options.
tealium.consentManager.userConsentCategories = setOf(ConsentCategory.CDP, ConsentCategory.EMAIL)
val categories = tealium.consentManager.userConsentCategories
// returns setOf(ConsentCategory.CDP, ConsentCategory.EMAIL)
userConsentStatus
Set or get the current consent status as granted by the app user. Available options are: UNKOWN
, CONSENTED
and NOT_CONSENTED
tealium.consentManager.userConsentPreferences = ConsentStatus.CONSENTED
val status = tealium.consentManager.userConsentStatus // returns ConsentStatus.CONSENTED
Interface: UserConsentPreferencesUpdatedListener
The UserConsentPreferencesUpdatedListener
is a listener interface. Register to receive the latest version updates of UserConsentPreferences
and ConsentPolicy
.
Method | Description |
---|---|
onUserConsentPreferencesUpdated() |
Gets or sets whether to log consent preference changes |
onUserConsentPreferencesUpdated()
Gets or sets whether to log consent preference changes. Implement the method on a class that implements the interface, or pass in an anonymous object after creating your Tealium
instance.
onUserConsentPreferencesUpdated(userConsentPreferences:policy:)
Parameters | Type | Description |
---|---|---|
userConsentPreferences |
UserConsentPreferences |
User consent preferences |
policy |
ConsentManagementPolicy |
Consent management policy |
Example:
val tealium = Tealium.create(...) {
events.subscribe(object : UserConsentPreferencesUpdatedListener {
override fun onUserConsentPreferencesUpdated(userConsentPreferences: UserConsentPreferences,
policy: ConsentManagementPolicy) {
Logger.dev(BuildConfig.TAG, "Consent preferences have been updated")
}
)}
)
}
This page was last updated: January 7, 2023