Reference
Last updated
Last updated
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).
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
Returns
Nothing
Example
Event types
The following events are supported by the Didomi SDK:
Listen for changes on the user status linked to a specific vendor.
Requires SDK to be initialized
No.
Parameters
Returns
Nothing
Example
Stop listening for changes on the user status linked to a specific vendor.
Requires SDK to be initialized
No.
Parameters
Returns
Nothing
Example
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.purposes?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.purposes?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.vendors?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.vendors?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.purposes?.global?.enabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.purposes?.global?.enabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced byuserStatus.vendors?.consent?.enabled
.
Removed since 2.0.0, use getUserStatus instead.
The result of this method has been replaced by userStatus.vendors?.consent?.enabled
.
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
Example
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.
Read our article on sharing consent with WebViews for more information.
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
Example
Get a purpose based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Returns
Example
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
Example
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
Example
Get the list of vendors that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Example
Get the list of vendor IDs that are required (determined from the configuration).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Example
Method used to get a dictionary/map based on the key being passed. These keys and texts are extracted from the notice content, preferences content and the texts
property specified in the didomi_config.json
file as described here https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-theme#translatable-texts-for-custom-notices.
Requires SDK to be initialized
Yes.
Parameters
Returns
Example
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:
Custom texts for the consent notice: https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-notice#texts
Custom texts for the preferences: https://developers.didomi.io/cmp/mobile-sdk/consent-notice/customize-the-preferences-popup#text
Custom texts for custom notices: https://developers.didomi.io/cmp/mobile-sdk/consent-notice/build-your-own-custom-notice#translatable-texts-for-custom-notices
Requires SDK to be initialized
Yes.
Parameters
Returns
Translated text.
Example
Removed since 2.0.0, use getUserStatus instead.
Search the purposeId in userStatus.purposes?.consent?.enabled
or userStatus.purposes?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
Search the vendorId in userStatus.vendors?.consent?.enabled
or userStatus.vendors?.consent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
Search the vendorId in userStatus.vendors?.globalConsent?.enabled
or userStatus.vendors?.globalConsent?.disabled
.
Removed since 2.0.0, use getUserStatus instead.
Search the purposeId in userStatus.purposes?.legitimateInterest?.enabled
or userStatus.purposes?.legitimateInterest?.getDisabled
.
Removed since 2.0.0, use getUserStatus instead.
Search the vendorId in userStatus.vendors?.legitimateInterest?.enabled
or userStatus.vendors?.legitimateInterest?.getDisabled
.
Removed since 2.0.0, use getUserStatus instead.
Search the vendorId in userStatus.vendors?.globalLegitimateInterest?.enabled
or userStatus.vendors?.globalLegitimateInterest?.disabled
.
Get all the user consent status.
Throws
Returns
A UserStatus
object describing all the available and computed user information.
Example
Deprecated, use getUserStatus instead.
Search the vendorId in userStatus.vendors?.global?.enabled
or userStatus.vendors?.global?.disabled
.
Get the user consent and legitimate interest status for a given vendor.
Parameters
Returns
A ConsentStatus
that indicates if the user has allowed both consent and legitimate interest data processing to the specific vendor.
If one of consent or legitimate interest data processing status is unknown or not allowed, disable
will be returned. If both are allowed by the user, the function will return enable
.
Example
Get a vendor based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Returns
Example
Hide the consent notice.
Parameters
No parameter.
Returns
Nothing
Example
Hide the preferences popup.
Parameters
No parameter.
Returns
Nothing
Example
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.
Parameters
The parameter disableDidomiRemoteConfig
is deprecated, we strongly suggest you to create your notice from the console (see Setup from the Console for more information).
Returns
Nothing
Example
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
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
Check if the consent notice is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
Check if the preferences popup is currently displayed.
Parameters
No parameter.
Returns
Future<bool>
Example
Check if the SDK is ready.
Parameters
No parameter.
Returns
Future<bool>
Example
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
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
Returns
Nothing
Example
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
Returns
Nothing
Example
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.
No parameter.
Returns
An instance of the CurrentUserStatusTransaction
class.
Description of the CurrentUserStatusTransaction
class
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.