This section is a comprehensive reference of the methods and events exposed by the Flutter SDK that you can leverage in your application.
These methods are accessible in the DidomiSdk class. Also make sure to always call the SDK after it is fully initialized (see onReady).
addEventListener
Add an event listener to catch events triggered by the SDK. Events listeners allow you to react to different events of interest. This function is safe to call before the ready event has been triggered.
Requires SDK to be initialized
No.
Parameters
Name
Type
Description
eventListener
EventListener
The event listener. An instance ofEventListener
Returns
Nothing
Example
EventListener didomiListener =EventListener();// SDK lifecycle eventsdidomiListener.onReady = () {onEvent("SDK Ready");};didomiListener.onError = (message) {onEvent("Error : $message");};// Notice eventsdidomiListener.onShowNotice = () {onEvent("Notice displayed");};didomiListener.onHideNotice = () {onEvent("Notice hidden");};didomiListener.onShowPreferences = () {onEvent("Preferences screen displayed");};didomiListener.onHidePreferences = () {onEvent("Preferences screen hidden");};didomiListener.onNoticeClickAgree = () {onEvent("Click Agree from Notice");};didomiListener.onNoticeClickDisagree = () {onEvent("Click Disagree from Notice");};didomiListener.onNoticeClickViewVendors = () {onEvent("Click View vendors from Notice");};didomiListener.onNoticeClickViewSPIPurposes = () {onEvent("Click View SPI from Notice");};didomiListener.onNoticeClickMoreInfo = () {onEvent("Click More info from Notice");};didomiListener.onNoticeClickPrivacyPolicy = () {onEvent("Click Privacy policy from Notice");};// Preferences screen eventsdidomiListener.onPreferencesClickAgreeToAll = () {onEvent("Click Agree to all from Preferences");};didomiListener.onPreferencesClickDisagreeToAll = () {onEvent("Click Disagree to all from Preferences");};didomiListener.onPreferencesClickPurposeAgree = (purposeId) {onEvent("Click Agree to purpose $purposeId from Preferences");};didomiListener.onPreferencesClickPurposeDisagree = (purposeId) {onEvent("Click Disagree to purpose $purposeId from Preferences");};didomiListener.onPreferencesClickCategoryAgree = (categoryId) {onEvent("Click Agree to category $categoryId from Preferences");};didomiListener.onPreferencesClickCategoryDisagree = (categoryId) {onEvent("Click Disagree to category $categoryId from Preferences");};didomiListener.onPreferencesClickViewVendors = () {onEvent("Click View vendors from Preferences");};didomiListener.onPreferencesClickViewSPIPurposes = () {onEvent("Click View SPI from Preferences");};didomiListener.onPreferencesClickSaveChoices = () {onEvent("Click Save choices from Preferences");};didomiListener.onPreferencesClickAgreeToAllPurposes = () {onEvent("Click Agree to all purposes from Preferences");};didomiListener.onPreferencesClickDisagreeToAllPurposes = () {onEvent("Click Disagree to all purposes from Preferences");};didomiListener.onPreferencesClickResetAllPurposes = () {onEvent("Click Reset all purposes from Preferences");};// Vendors screen eventsdidomiListener.onPreferencesClickVendorAgree = (vendorId) {onEvent("Click Agree to vendor $vendorId from Preferences");};didomiListener.onPreferencesClickVendorDisagree = (vendorId) {onEvent("Click Disagree to vendor $vendorId from Preferences");};didomiListener.onPreferencesClickVendorSaveChoices = () {onEvent("Click Save vendor choices from Preferences");};didomiListener.onPreferencesClickViewPurposes = () {onEvent("Click View purposes from Preferences");};didomiListener.onPreferencesClickAgreeToAllVendors = () {onEvent("Click Agree to all vendors from Preferences");};didomiListener.onPreferencesClickDisagreeToAllVendors = () {onEvent("Click Disagree to all vendors from Preferences");};// SPI screen eventsdidomiListener.onPreferencesClickSPIPurposeAgree = (purposeId) {onEvent("Click Agree to SPI purpose $purposeId from Preferences");};didomiListener.onPreferencesClickSPIPurposeDisagree = (purposeId) {onEvent("Click Disagree to SPI purpose $purposeId from Preferences");};didomiListener.onPreferencesClickSPICategoryAgree = (categoryId) {onEvent("Click Agree to SPI category $categoryId from Preferences");};didomiListener.onPreferencesClickSPICategoryDisagree = (categoryId) {onEvent("Click Disagree to SPI category $categoryId from Preferences");};didomiListener.onPreferencesClickSPIPurposeSaveChoices = () {onEvent("Click Save SPI choices from Preferences");};// Consent eventsdidomiListener.onConsentChanged = () {onEvent("Consent has changed");};didomiListener.onSyncReady = (event) {onEvent("Sync is complete. Status applied: ${event.statusApplied}");if (event.statusApplied) {print("User status has been applied locally."); }if (event.syncAcknowledged()) {print("sync.acknowledged API event has been triggered successfully."); }};didomiListener.onSyncDone = (organizationUserId) {onEvent("Sync has been done for user $organizationUserId");};didomiListener.onSyncError = (error) {onEvent("Sync failed with error $error");};// Language change eventsdidomiListener.onLanguageUpdated = (languageCode) {onEvent("Language has changed ($languageCode)");};didomiListener.onLanguageUpdateFailed = (reason) {onEvent("Language has not changed: $reason");};DidomiSdk.addEventListener(didomiListener);
Event types
The following events are supported by the Didomi SDK:
Method
Description
onReady
When the SDK is ready.
onError
When the SDK encountered an error (message provided as parameter).
onShowNotice
When the consent notice gets displayed. If you have disabled our default consent notices to replace them with your own, you need to show your custom notice when this event gets triggered.
onHideNotice
When the consent notice is hidden. If you have disabled our default consent notice to replace it with your own, you need to hide your custom notice when this event gets triggered.
onShowPreferences
When the preferences screen is displayed.
onHidePreferences
When the preferences screen is hidden.
onNoticeClickAgree
When user clicks on agree on the notice.
onNoticeClickDisagree
When user clicks on disagree on the notice.
onNoticeClickViewVendors
When user clicks on partners on the notice.
onNoticeClickViewSPIPurposes
When user clicks on view Sensitive Personal Information on the preferences popup.
onNoticeClickMoreInfo
When user clicks on learn more on the notice.
onNoticeClickPrivacyPolicy
When user clicks on privacy policy on the notice.
onPreferencesClickAgreeToAll
When user clicks on agree to all on the preferences popup.
onPreferencesClickDisagreeToAll
When user clicks on disagree to all on the preferences popup.
onPreferencesClickPurposeAgree
When user agree to a purpose on the preferences popup (purposeId provided as parameter).
onPreferencesClickPurposeDisagree
When user disagree to a purpose on the preferences popup (purposeId provided as parameter).
onPreferencesClickCategoryAgree
When user agree to a category on the preferences popup (categoryId provided as parameter).
onPreferencesClickCategoryDisagree
When user disagree to a category on the preferences popup (categoryId provided as parameter).
onPreferencesClickViewVendors
When user clicks on view vendors on the preferences popup.
onPreferencesClickViewSPIPurposes
When user clicks on view Sensitive Personal Information on the preferences popup.
onPreferencesClickSaveChoices
When user saves his choice on the preferences popup.
onPreferencesClickAgreeToAllPurposes
When user flips ON all purposes switch on the preferences popup.
onPreferencesClickDisagreeToAllPurposes
When user flips OFF all purposes switch on the preferences popup.
onPreferencesClickResetAllPurposes
When user reset all purposes switch on the preferences popup.
onPreferencesClickVendorAgree
When user agree to a vendor on the preferences popup (vendorId provided as parameter).
onPreferencesClickVendorDisagree
When user disagree to a vendor on the preferences popup (vendorId provided as parameter).
onPreferencesClickVendorSaveChoices
When user saves his choice on the vendors view on the preferences popup.
onPreferencesClickViewPurposes
When user clicks on view purposes on the preferences popup.
onPreferencesClickAgreeToAllVendors
When user flips ON all vendors switch on the preferences popup.
onPreferencesClickDisagreeToAllVendors
When user flips OFF all vendors switch on the preferences popup.
onPreferencesClickSPIPurposeAgree
When user agree to a purpose on the Sensitive Personal Information view from the preferences popup (purposeId provided as parameter).
onPreferencesClickSPIPurposeDisagree
When user disagree to a purpose on the Sensitive Personal Information view from the preferences popup (purposeId provided as parameter).
onPreferencesClickSPICategoryAgree
When user agree to a category on the Sensitive Personal Information view from the preferences popup (categoryId provided as parameter).
onPreferencesClickSPICategoryDisagree
When user disagree to a category on the Sensitive Personal Information view from preferences popup (categoryId provided as parameter).
onPreferencesClickSPIPurposeSaveChoices
When user saves his choice on the Sensitive Personal Information view from preferences popup.
onConsentChanged
When a consent is given or withdrawn by the user. Only triggered when the consent status actually changes (ie if the user saves consents without adding/removing any consent then this does not get called).
onSyncReady
When the consent synchronization process is complete.
event parameter is a SyncReadyEvent object that contains the fields statusApplied and syncAcknowledged (see below)
SyncReadyEvent.statusApplied
Whether the user status was applied locally
SyncReadyEvent.syncAcknowledged
Function that triggers a sync.acknowledged API event when called. It returns true if the API event was sent successfully.
onSyncDone
When the consent synchronization is successful (organizationUserId provided as parameter).
onSyncError
When the consent synchronization has failed (error provided as parameter).
onLanguageUpdated
When the language has changed (languageCode provided as parameter).
onLanguageUpdateFailed
When the language change has failed (reason provided as parameter).
addVendorStatusListener
Listen for changes on the user status linked to a specific vendor.
Requires SDK to be initialized
No.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor for which we want to start listening for changes.
This ID should be the ID provided by Didomi, which doesn't contain prefixes.
listener
Function(VendorStatus)
Method that will be executed whenever changes are detected on the specified vendor. When this callback is executed, the status linked to the specified vendor will be passed.
Returns
Nothing
Example
removeVendorStatusListener
Stop listening for changes on the user status linked to a specific vendor.
Requires SDK to be initialized
No.
Parameters
Name
Type
Description
vendorId
String
The ID of the vendor for which we want to stop listening for changes.
This ID should be the ID provided by Didomi, which doesn't contain prefixes.
Returns
Nothing
Example
getJavaScriptForWebView
Get JavaScript to embed into a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.
Inject the returned tag into a WebView with evaluateJavaScript.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<String>
JavaScript code to embed in a WebView
Example
getQueryStringForWebView
Get a query string parameter to append to the URL of a WebView to pass the consent status from the app to the Didomi Web SDK embedded into the WebView.
This method is currently available on Android platform only. Calling getQueryStringForWebView on iOS platform will return an empty String.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<String>
Query string parameter with the format didomiConfig.user.externalConsent.value=.... It can be appended to your URL after a ? or a & if your URL already contains a query string.
Example
getPurpose
Get a purpose based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
purposeId
String
ID of the purpose we want to get.
Returns
Type
Description
Future<Purpose?>
A Purpose with ID purposeId found in the array of required purposes, or null.
Example
getRequiredPurposes
Get the list of purpose that are required (automatically determined from the list of required vendors).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Purpose>>
A list of type Purpose containing the required purposes.
Example
getRequiredPurposeIds
Get the list of purpose IDs that are required (automatically determined from the list of required vendors).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of required purposes.
Example
getRequiredVendors
Get the list of vendors that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<Vendor>>
A list of type Vendor containing the required vendors.
Example
getRequiredVendorIds
Get the list of vendor IDs that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type
Description
Future<List<String>>
A list of type String containing the IDs of required vendors.
key associated to the dictionary that we want to get.
Returns
Type
Description
Dictionary/map: Future<Map<String, String>>
Dictionary/map containing the translations for an specific key in different languages, with the form { "en:" "text in English", "fr": "texte en Français" }
Example
getTranslatedText
Method used to get a translated text based on the key being passed.
The language and the source of this translated text will depend on the availability of the translation for the specific key.
The language being used will be either the selected language of the SDK (based on device Locale and other parameters) or the language specified by app developers as the default language being used by the SDK. The source can be either the didomi_config.json file, which can be either local or remote, or a file that is bundled within the SDK.
These are the attempts performed by the SDK to try to find a translation for the specific key:
Get translated value in user locale (selected language) from didomi_config.json (either local or remote).
Get translated value in default locale (from the config) from didomi_config.json (either local or remote).
Get translated value in user locale (selected language) from the Didomi-provided translations (bundled within the Didomi SDK).
Get translated value in default locale (from the config) from the Didomi-provided translations (bundled within the Didomi SDK).
If no translation can be found after these 4 attempts, the key will be returned.
App developers can provide these translated texts through the didomi_config.json file (locally or remotely) in 3 different ways:
key associated to the text that we want to get translated.
Returns
Translated text.
Example
getCurrentUserStatus
Exposes the user status for the current regulation that applies.
Requires SDK to be initialized
Yes.
Parameters
No parameters.
Returns
The user status containing the computed global status for Vendors and purposes:
A vendor's global status is enabled, if and only if:
the vendor is enabled directly in the vendors layer in all legal basis
AND all its related purposes are enabled or essential.
A purpose's global status is enabled in one of the two conditions:
the purpose is enabled for all the legal basis that it is configured for.
OR when the purpose is essential.
Parameter
Type
Description
didomiDcs
string
Didomi Consent String that stores end-user choices for custom and Google ATP vendors, and custom and global purposes across all regulations. Click here for more information.
vendors
object
Dictionary that maps the ID of a vendor to an object representing its status.
The IDs used in this dictionary correspond to the Didomi IDs i.e.: without the c: or any other prefix.
Vendors with undefined user status are included in the response with enabled: false.
Vendors with ONLY essential purposes are automatically set with enable: true
purposes
object
Dictionary that maps the ID of a purpose to an object representing its status.
Purposes with undefined user status are included in the response with enabled: false.
Essential purposes are automatically set with enable: true
regulation
String
Representation of the current regulation as a Regulation enum value, such as GDPR, CCPA, CPRA, or NONE.
Note that some regulations present as enum values are not available yet.
userId
String
Didomi user id.
created
String
User choices creation date.
updated
String
User choices update date.
consentString
String
TCF consent as string
additionalConsent
String
Additional consent.
gppString
String
GPP string.
Throws
Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.
getVendor
Get a vendor based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
vendorId
String
ID of the vendor we want to get.
Returns
Type
Description
Future<Vendor?>
A Vendor with ID vendorId found in the array of required vendors, or null.
Example
hideNotice
Hide the consent notice.
Parameters
No parameter.
Returns
Nothing
Example
hidePreferences
Hide the preferences popup.
Parameters
No parameter.
Returns
Nothing
Example
initializeWithParameters
Initialize the SDK. The initialization runs on a background thread to avoid blocking your UI. Use the onReady function to know when the initialization is done and the SDK is ready to be used.
Parameter
Name
Type
Description
didomiInitializeParameters
DidomiInitializeParameters
Object containing properties required to initilalize the SDK.
Description forDidomiInitializeParameters:
The parameter disableDidomiRemoteConfig is deprecated, we strongly suggest you to create your notice from the console (see Setup from the Console for more information).
Name
Type
Description
apiKey
String
Your API key
localConfigurationPath
String?
Optional. The path to your local config file in your assets/ folder. Defaults to didomi_config.json if null.
remoteConfigurationPath
String?
Optional. The URL to a remote configuration file to load during initialization. When provided, the file at the URL will be downloaded and cached to be used instead of the local assets/didomi_config.json. If there is no Internet connection available and no previously cached file, the local file will be used as fallback.
providerId
String?
Optional. Your provider ID (if any). A provider ID is assigned when you work with Didomi through a third-party. If are not sure if you have one, set this to null.
disableDidomiRemoteConfig
bool
Prevent the SDK from loading a remote configuration from the Didomi Console. Defaults to false (loading remote config).
Set this parameter to false to use a remote consent notice configuration loaded from the Didomi Console.
Set this parameter to true to disable loading configurations from the Didomi Console.
languageCode
String?
Optional. Language in which the consent UI should be displayed. By default, the consent UI is displayed in the language configured in the device settings. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code or the local code e.g.: "es", "fr", "en-US","zh-HK", etc.
noticeId
String?
Optional. Notice ID to load the configuration from. If provided, the SDK bypasses the app ID targeting and directly loads the configuration from the notice ID.
androidTvNoticeId
String?
Optional. TV notice ID to load the configuration from. If provided and SDK is initialized on TV, the SDK bypasses the app ID targeting and directly loads the configuration from the notice ID.
androidTvEnabled
bool
Enable the Android TV SDK. Defaults to false (Android TV is not enabled).
This parameter will be checked if sdk is initialized from a TV device.
If set to false, the sdk initialization will fail with an error.
If set to true, the sdk will try to initialize in TV mode, using the API key and the optional tvNoticeId parameter.
Please note that the TV notice option must be enabled on Didomi side. Please reach out to your dedicated customer success manager to know more.
countryCode
String?
Optional. Override user country code when determining the privacy regulation to apply.
Keep null to let the Didomi SDK determine the user country.
regionCode
String?
Optional. Override user region code when determining the privacy regulation to apply.
Keep null to let the Didomi SDK determine the user region.
Ignored if countryCode is not set.
isUnderage
bool
Whether the user is underage or not. This parameters can only be used if the Underage feature has been configured in your notice. (Underage is currently in beta version).
Returns
Nothing
Example
isConsentRequired
Determine if consent is required for the user. This takes into account the location of the user and the configuration of the SDK:
If your app is configured to apply GDPR to all users then this function always returns true.
If your app is configured to apply GDPR to EU users only then this function returns true only if the user in the EU.
Parameters
No parameter.
Returns
Future<bool>
Example
isUserConsentStatusPartial
Determine if all consent information is available for the user.
This function returns true if and only if:
Consent is required for the user (ie the user is in the EU or your tag is configured to apply GDPR to all users)
At least one vendor is configured (if there is no vendor configured, this function always returns false as there is no consent to collect)
We miss consent information for some vendors or purposes
If there is at least one piece of consent information missing for a single vendor/purpose, this function will return true. The consent notice is usually displayed when this function returns true although there is no guarantee of the direct mapping between the two.
An important edge case is when you add new vendors or if configured vendors ask for new purposes: the consent notice will be displayed again and this function will return true until the user has given or denied consent. Vendors that already had consent before will still operate normally as we only recollect consent for additional vendors/purposes.
Parameters
No parameter.
Returns
Future<bool>
Example
isNoticeVisible
Check if the consent notice is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
isPreferencesVisible
Check if the preferences popup is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
isReady
Check if the SDK is ready.
Parameters
No parameter.
Returns
Future<bool>
Example
isUserStatusPartial
Determine if the user has provided a choice for all vendors selected for the regulation and linked data processing.
This function returns true if the user has not expressed a choice for all the required vendors and data processing.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Future<bool>
Example
onError
Add a callback that will be called when the SDK initialization encounters an error. If the callback is added after the SDK initialization already failed, it will be called immediately.
Parameters
Name
Type
Description
callback
Function()
A callback to run when the SDK initialization encounters an error
Returns
Nothing
Example
onReady
Add a callback that will be called when the SDK is ready (ie fully initialized). If the callback is added after the SDK initialization, it will be called immediately.
All calls to other functions of this API must only be made in a callback to the ready event to make sure that the SDK is initialized before it is used.
Parameters
Name
Type
Description
callback
Function()
A callback to run when the SDK is ready
Returns
Nothing
Example
openCurrentUserStatusTransaction
Definition
Create an instance of the CurrentUserStatusTransaction class.
This class provides mechanisms to stage updates to the user status regarding purposes and vendors, allowing for batch operations.
Updates made through its methods are queued and applied simultaneously to the user status only once the commit method of the returned object is called.
Additional details:
The status of vendors and purposes whose IDs are not not specified through the methods provided by CurrentUserStatusTransaction are kept unchanged.
Essential purposes are always set to enabled and can’t be updated by the methods provided by CurrentUserStatusTransaction.
When the regulation applied for a user is none, the methods provided by CurrentUserStatusTransaction should not update the status of any vendor or purpose which will always remain as enabled. When the commit method is called it will return false.
If the IDs that are passed through the methods provided by CurrentUserStatusTransaction don’t correspond to vendors or purposes required by the Notice Config, they will be ignored.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
An instance of the CurrentUserStatusTransaction class.
Description of theCurrentUserStatusTransactionclass
Method
Parameters
Returns
Description
enablePurpose
id (String): ID of the purpose to be enabled.
Current CurrentUserStatusTransaction object.
Enable a single purpose based on its ID.
enablePurposes
ids (List<String>): IDs of the purposes to be enabled.
Current CurrentUserStatusTransaction object.
Enable multiple purposes based on their IDs.
disablePurpose
id (String): ID of the purpose to be disabled.
Current CurrentUserStatusTransaction object.
Disable a single purpose based on its ID.
disablePurposes
ids (List<String>): IDs of the purposes to be disabled.
Current CurrentUserStatusTransaction object.
Disable multiple purposes based on their IDs.
enableVendor
id (String): Didomi ID of the vendor to be enabled.
Current CurrentUserStatusTransaction object.
Enable a single vendor based on its Didomi ID.
enableVendors
ids (List<String>): Didomi IDs of the vendors to be enabled.
Current CurrentUserStatusTransaction object.
Enable multiple vendors based on their Didomi IDs.
disableVendor
id (String): Didomi ID of the vendor to be disabled.
Current CurrentUserStatusTransaction object.
Disable a single vendor based on its Didomi ID.
disableVendors
ids (List<String>): Didomi IDs of the vendors to be disabled.
Current CurrentUserStatusTransaction object.
Disable multiple vendors based on their Didomi IDs.
commit
No parameters.
bool: true if user status has been updated, false otherwise.
Commit the changes that have been made through other methods.
Examples
setLogLevel
Set the minimum level of messages to log. The SDK will not log messages under that level.
It uses a LogLevel object which maps log levels to corresponding values in iOS / Android native platforms.
Setup the SDK UI. By calling this method, the consent notice will be displayed once the SDK is ready and if consent should be collected. It does not show any view if consent was already collected or is not required.
This method should be called only from your contexts where the application starts.
Set custom user information from organization, with authentication parameters.
Parameters
Name
Type
Description
organizationUserId
String
Organization ID to associate with the user
organizationUserIdAuthAlgorithm
String
Algorithm used for computing the digest
organizationUserIdAuthSid
String
ID of the secret used for computing the digest
organizationUserIdAuthSalt
String?
Salt used for computing the digest (optional)
organizationUserIdAuthDigest
String
Digest of the organization user ID and secret
Returns
Nothing
Example
setUserWithParameters
Set custom user information from organization, with or without authentication parameters.
Parameter:
Name
Type
Description
didomiUserParameters
DidomiUserParameters
Object containing properties required to set a user.
Description forDidomiUserParameters:
Name
Type
Description
userAuth
UserAuth
User authentication object. Can be either UserAuthWithoutParams, UserAuthWithEncryptionParams or UserAuthWithHashParams.
dcsUserAuth
UserAuthParams?
Optional. Dedicated user with encryption or hash used for Didomi Consent String signature. Can be either UserAuthWithEncryptionParams or UserAuthWithHashParams.
This parameter can only be used if you are using the Didomi Consent String feature (This feature is currently in beta version)
isUnderage
Boolean?
Optional. Whether the user is underage or not. This parameters can only be used if the Underage feature has been configured in your notice. (Underage is currently in beta version).
Parameters for UserAuthWithoutParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
Parameters for UserAuthWithEncryptionParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
algorithm
String
Algorithm used for computing the user ID.
secretId
String
ID of the secret used for the computing the user ID.
initializationVector
String
Initialization Vector used for encrypting the message.
expiration
Long?
Optional. Expiration time as UNIX timestamp (must be > 0).
Parameters for UserAuthWithHashParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
algorithm
String
Algorithm used for computing the user ID.
secretId
String
ID of the secret used for the computing the user ID.
digest
String
Digest used for representing the user ID
salt
String?
Optional. Salt used for computing the user ID.
expiration
Long?
Optional. Expiration time as UNIX timestamp (must be > 0)
Returns
Nothing
Example
setUserWithParametersAndSetupUI
Set custom user information from organization, with or without authentication parameters and display the notice if required.
Parameter:
Name
Type
Description
didomiUserParameters
DidomiUserParameters
Object containing properties required to set a user.
Description forDidomiUserParameters:
Name
Type
Description
userAuth
UserAuth
User authentication object. Can be either UserAuthWithoutParams, UserAuthWithEncryptionParams or UserAuthWithHashParams.
dcsUserAuth
UserAuthParams?
Optional. Dedicated user with encryption or hash used for Didomi Consent String signature. Can be either UserAuthWithEncryptionParams or UserAuthWithHashParams.
This parameter can only be used if you are using the Didomi Consent String feature (This feature is currently in beta version)
isUnderage
Boolean?
Optional. Whether the user is underage or not. This parameters can only be used if the Underage feature has been configured in your notice. (Underage is currently in beta version).
Parameters for UserAuthWithoutParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
Parameters for UserAuthWithEncryptionParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
algorithm
String
Algorithm used for computing the user ID.
secretId
String
ID of the secret used for the computing the user ID.
initializationVector
String
Initialization Vector used for encrypting the message.
expiration
Long?
Optional. Expiration time as UNIX timestamp (must be > 0).
Parameters for UserAuthWithHashParams :
Name
Type
Description
id
String
Organization ID to associate with the user.
algorithm
String
Algorithm used for computing the user ID.
secretId
String
ID of the secret used for the computing the user ID.
digest
String
Digest used for representing the user ID
salt
String?
Optional. Salt used for computing the user ID.
expiration
Long?
Optional. Expiration time as UNIX timestamp (must be > 0)
Returns
Nothing
Example
clearUser
Remove custom user information from organization
Parameters
No parameter.
Returns
Nothing
Example
showNotice
In most cases this method should be called if the notice should be displayed in response to a user action (e.g.: select the privacy settings section within your app). By calling the setupUI method, the notice will be automatically displayed if required.
Show the consent notice. The consent notice actually only gets shown if needed (consent is required and we are missing consent information for some vendor or purpose).
Returns
Nothing
Example
showPreferences
In most cases this method should be called if you want to show the Preferences screen in response to a user action (the user pressing a "Consent Preferences" button in your app menu, for instance).
Show the Preferences view to the user. This method can be used to allow the user to update their preferences after the banner has been closed. We suggest adding a link/button/item that calls this method somewhere in your app, for example from your settings menu. By default, the Purposes view is displayed first. By calling this method, users will have the opportunity to modify the choices previously made.
Parameters
Type
PreferencesView (Optional)
Defines which view is displayed to the user first between the purposes view or the vendors view. We expose the values to provide on the Didomi class as PreferencesView.purposes, PreferencesView.sensitivePersonalInformation and PreferencesView.vendors. If this parameter is not defined or contains an unexpected string, the purposes' view will be displayed.
Returns
Nothing
Example
reset
Reset all the consent information for the current user. This will remove all consent information stored on the device by Didomi and will trigger re-collection of consent. The consent notice will be displayed again.
Parameters
No parameter.
Returns
Nothing
Example
setUserAgreeToAll
Report that the user has enabled consents and legitimate interests for all purposes and vendors configured for your app.
This function will log the user choice on our platform and close the notice.
Consent statuses for essential purposes are not stored.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Parameters
No parameter.
Returns
Future<bool>
true if the user choices have changed (i.e. the user had made different choices before this function got called).
Example
setUserDisagreeToAll
Report that the user has disabled consents and legitimate interests for all purposes and vendors configured for your app.
This function will log the user choice on our platform and close the notice.
Consent statuses for essential purposes are not stored.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Parameters
No parameter.
Returns
Future<bool>
true if the user choices have changed (i.e. the user had made different choices before this function got called).
Example
setCurrentUserStatus
Definition
Set the user status for purposes and vendors. This function will trigger events and API calls every time it is called (and the user status changes) so make sure to push all user choices at once and not one by one.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Parameters
Add the desired global status for each vendor and each purpose:
the vendor status specified in this function will be reflected on the vendor’s layer.
vendor enabled : true → means the vendor is enabled in all the legal basis that this vendor uses.
vendor enabled : false → means the vendor is disabled in all the legal basis that this vendor uses
the purposes status specified in this function will be reflected on the preferences layer.
purpose enabled : true → means the purpose is enabled in all the legal basis in which it’s defined.
purpose enabled : false → means the purpose is disabled in all the legal basis in which it’s defined.
Returns
boolean
true if the user choices have changed (i.e. the user had made different choices before this function got called).
Throws
Type
Description
DidomiNotReadyException
Exception thrown when a method that requires the Didomi SDK to be ready is called before that. Developers can call this method within a try/catch or within a lambda expression passed into the onReady method.
Example
setUserStatusGlobally
Set the global status for consent purposes, legitimate interest purposes, consent vendors, legitimate interest vendors. This function will trigger events and API calls every time it is called.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Name
Type
Description
purposesConsentStatus
bool
true if purposes on a consent basis should be enabled, false if they should be disabled
purposesLIStatus
bool
true if purposes on a legitimate interest basis should be enabled, false if they should be disabled
vendorsConsentStatus
bool
true if vendors on a consent basis should be enabled, false if they should be disabled
vendorsLIStatus
bool
true if vendors on a legitimate interest basis should be enabled, false if they should be disabled
Returns
Future<bool>
true if the user choices have changed (i.e. the user had made different choices before this function got called).
Determine if consent should be collected for the visitor. Returns true if consent is required for the current user and one of following two conditions is met:
Consent has never been collected for this visitor yet
New consents should be collected (as new vendors have been added) AND the number of days before recollecting them has exceeded
If none of these two conditions is met, the function returns false. This function is mainly present to allow you to know when to display your own notice if you have disabled our standard notice.
Parameters
No parameter.
Returns
Future<bool>
Example
shouldUserStatusBeCollected
Determine if user status (consent) should be collected for the user. Returns true if status is required for the current user and one of following two conditions is met:
User status has never been collected for this user yet
New user status should be collected (as new vendors have been added) AND the number of days before recollecting them has exceeded
If none of these two conditions is met, the function returns False. This function is mainly present to allow you to know when to display your own notice if you have disabled our standard notice.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Future<bool>
Example
updateSelectedLanguage
Method used to update the selected language of the Didomi SDK and any property that depends on it.
In most cases this method doesn't need to be called. It would only be required for those apps that allow language change on-the-fly, i.e.: from within the app rather than from the device settings.
If your configuration involves country code (en-US), you can provide a locale code to change the regional configuration as well. If only language code (en) is provided and your configuration requires a country code, the country from the device location will be used (and will fallback to the default country if required).
In order to update the language of the views displayed by the Didomi SDK, this method needs to be called before these views are displayed.
Requires SDK to be initialized
Yes.
Parameters
Name
Type
Description
languageCode
String
string containing the 2-letter language code or 5-letter locale code e.g. en, es, fr, en-US, zh-HK, etc.
Returns
Nothing
Example
Type
Description
Future<List<Purpose>>
A list of type Purpose containing the purposes disabled by the user.
applicableRegulation
Get the applicable regulation.
Requires SDK to be initialized
yes.
Returns
Type
Description
String
Representation of the current regulation as a Regulation String value, such as GDPR, CCPA, CPRA, or NONE.
Note that some regulations present as enum values are not available yet.