Reference
Reference
This section is a comprehensive reference of the methods and events exposed by the react-native SDK that you can leverage in your application.
These methods are accessible in the Didomi
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 |
---|---|---|
eventType |
| The type of event to listen to |
callback |
| Callback to call when event occurs. |
Event types
DidomiEventType
is an enum with the following values:
These events are supported by the Didomi SDK:
Value | Description |
CONSENT_CHANGED | 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). |
ERROR | When the SDK encountered an error ( |
READY | When the SDK is ready. |
HIDE_NOTICE | 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. |
SHOW_NOTICE | 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. |
NOTICE_CLICK_AGREE | When user clicks on agree on the notice. |
NOTICE_CLICK_DISAGREE | When user clicks on disagree on the notice. |
NOTICE_CLICK_VIEW_VENDORS | When user clicks on Partners on the notice. |
NOTICE_CLICK_VIEW_SPI_PURPOSES | When user clicks on Sensitive Personal Information on the notice. |
NOTICE_CLICK_MORE_INFO | When user clicks on learn more on the notice. |
NOTICE_CLICK_PRIVACY_POLICY | When user clicks on privacy policy on the notice. |
HIDE_PREFERENCES | When the preferences screen is hidden. |
SHOW_PREFERENCES | When the preferences screen is displayed. |
PREFERENCES_CLICK_VIEW_PURPOSES | When user clicks on view purposes on the preferences popup. |
PREFERENCES_CLICK_VIEW_VENDORS | When user clicks on view vendors on the preferences popup. |
PREFERENCES_CLICK_VIEW_SPI_PURPOSES | When user clicks on view Sensitive Personal Information on the preferences popup. |
PREFERENCES_CLICK_AGREE_TO_ALL | When user clicks on agree to all on the preferences popup. |
PREFERENCES_CLICK_DISAGREE_TO_ALL | When user clicks on disagree to all on the preferences popup. |
PREFERENCES_CLICK_AGREE_TO_ALL_PURPOSES | When user flips ON all purposes switch on the preferences popup. |
PREFERENCES_CLICK_DISAGREE_TO_ALL_PURPOSES | When user flips OFF all purposes switch on the preferences popup. |
PREFERENCES_CLICK_RESET_ALL_PURPOSES | When user resets all purposes switch on the preferences popup. |
PREFERENCES_CLICK_PURPOSE_AGREE | When user agree to a purpose on the preferences popup. ( |
PREFERENCES_CLICK_PURPOSE_DISAGREE | When user disagree to a purpose on the preferences popup. ( |
PREFERENCES_CLICK_CATEGORY_AGREE | When user agree to a category on the preferences popup ( |
PREFERENCES_CLICK_CATEGORY_DISAGREE | When user disagree to a category on the preferences popup ( |
PREFERENCES_CLICK_SAVE_CHOICES | When user saves his choice on the preferences popup. |
PREFERENCES_CLICK_AGREE_TO_ALL_VENDORS | When user flips ON all vendors switch on the preferences popup. |
PREFERENCES_CLICK_DISAGREE_TO_ALL_VENDORS | When user flips OFF all vendors switch on the preferences popup. |
PREFERENCES_CLICK_VENDOR_AGREE | When user agree to a vendor on the preferences popup ( |
PREFERENCES_CLICK_VENDOR_DISAGREE | When user disagree to a vendor on the preferences popup ( |
PREFERENCES_CLICK_VENDOR_SAVE_CHOICES | When user saves his choice on the vendors view from the preferences popup. |
PREFERENCES_CLICK_SPI_PURPOSE_AGREE | When user agree to a purpose on the Sensitive Personal Information view from preferences popup. ( |
PREFERENCES_CLICK_SPI_PURPOSE_DISAGREE | When user disagree to a purpose on Sensitive Personal Information view from the preferences popup. ( |
PREFERENCES_CLICK_SPI_CATEGORY_AGREE | When user agree to a category on the Sensitive Personal Information view from preferences popup ( |
PREFERENCES_CLICK_SPI_CATEGORY_DISAGREE | When user disagree to a category on the Sensitive Personal Information view from preferences popup ( |
PREFERENCES_CLICK_SPI_PURPOSE_SAVE_CHOICES | When user saves his choice on the Sensitive Personal Information view from preferences popup. |
SYNC_READY | When the consent synchronization process is over.
|
| Whether the user status was applied |
| Function that triggers a |
SYNC_DONE | Deprecated, use When the consent synchronization is successful ( |
SYNC_ERROR | When the consent synchronization has failed ( |
LANGUAGE_UPDATED | When the language has changed ( |
LANGUAGE_UPDATE_FAILED | When the language change has failed ( |
Returns
Nothing
Example
addVendorStatusListener
Listen for changes on the user status linked to a specific vendor.
Requires SDK to be initialized
No.
Parameters
Name | Type | Description |
---|---|---|
vendorId |
| 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. |
callback | callback: | Callback 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 |
| 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
getDisabledPurposes
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().purposes.consent.disabled
.
getDisabledPurposeIds
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().purposes.consent.disabled
.
getDisabledVendors
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().vendors.consent.disabled
.
getDisabledVendorIds
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().vendors.consent.disabled
.
getEnabledPurposes
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().purposes.global.enabled
.
getEnabledPurposeIds
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().purposes.global.enabled
.
getEnabledVendors
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().vendors.consent.enabled
.
getEnabledVendorIds
Removed since version 2.0.0, use getUserStatus instead.
The result of this method has been replaced by getUserStatus().vendors.consent.enabled
.
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 |
---|---|
| 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.
Read our article on sharing consent with WebViews for more information.
This method is currently available on Android platform only.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Type | Description |
---|---|
| Query string parameter with the format |
Example
getPurpose
Get a purpose based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name | Type | Description |
---|---|---|
purposeId |
| ID of the purpose we want to get. |
Returns
Type | Description |
---|---|
| A |
Purpose
interface is defined in DidomiTypes.ts
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 |
---|---|
| A list of type |
Purpose
interface is defined in DidomiTypes.ts
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 |
---|---|
| A list of type |
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 |
---|---|
| A list of type |
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 |
---|---|
| A list of type |
Example
getText
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
Name | Type | Description |
---|---|---|
key | String | key associated to the dictionary that we want to get. |
Returns
Type | Description |
---|---|
Dictionary/map: | Dictionary/map containing the translations for a 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:
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
Name | Type | Description |
---|---|---|
key | string | key associated to the text that we want to get translated. |
Returns
Translated text.
Example
getUserConsentStatusForPurpose
Deprecated, use getUserStatus instead.
Search the purposeId in getUserStatus().purposes.consent.enabled
or getUserStatus().purposes.consent.disabled
.
Get the user consent status for a given purpose. You must also check that the user has given consent to a vendor before being able to load a vendor.
Parameters
Name | Type | Description |
---|---|---|
purposeId | string | The ID of the purpose to check the user consent for |
Returns
A Promise<boolean>
that indicates if the user has given consent or not to the specific purpose.
undefined
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat undefined
as false
(ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return true
.
Example
getUserConsentStatusForVendor
Removed since version 2.0.0, use getUserStatus instead.
Search the vendorId in getUserStatus().vendors.consent.enabled
or getUserStatus().vendors.consent.disabled
.
getUserConsentStatusForVendorAndRequiredPurposes
Removed since version 2.0.0, use getUserStatus instead.
Search the purposeId in getUserStatus().vendors.global_consent.enabled
or getUserStatus().vendors.global_consent.disabled
.
getUserLegitimateInterestStatusForPurpose
Removed since version 2.0.0, use getUserStatus instead.
Search the purposeId in getUserStatus().purposes.legitimate_interest.enabled
or getUserStatus().purposes.legitimate_interest.disabled
.
getUserLegitimateInterestForVendor
Removed since version 2.0.0, use getUserStatus instead.
Search the vendorId in getUserStatus().vendors.legitimate_interest.enabled
or getUserStatus().vendors.legitimate_interest.disabled
.
getUserLegitimateInterestStatusForVendorAndRequiredPurposes
Removed since version 2.0.0, use getUserStatus instead.
Search the vendorId in getUserStatus().vendors.global_legitimate_interest.enabled
or getUserStatus().vendors.global_legitimate_interest.disabled
.
getUserStatus
Get all the user consent status.
Returns
A UserStatus
object describing all the available and computed user information.
Parameter | Type | Description |
---|---|---|
purposes.global.disabled | string[] | Computed sets/lists of disabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis. |
purposes.global.enabled | string[] | Computed sets/lists of enabled IDs of purposes that have been chosen by the user regarding the consent or legitimate interest Legal Basis. Purposes considered as essential will be part of the enabled IDs. |
purposes.consent.disabled | string[] | Disabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis. |
purposes.consent.enabled | string[] | Enabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis. |
purposes.legitimate_interest.disabled | string[] | Disabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis. |
purposes.legitimate_interest.enabled | string[] | Enabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis. |
purposes.essential | string[] | IDs of purposes that are considered essential. |
vendors.global.disabled | string[] | Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.global.enabled | string[] | Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent or legitimate interest Legal Basis. This takes into account the consent and legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.global_consent.disabled | string[] | Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.global_consent.enabled | string[] | Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the consent Legal Basis. This takes into account the consent required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.global_legitimate_interest.disabled | string[] | Computed sets/lists of disabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.global_legitimate___interest.enabled | string[] | Computed sets/lists of enabled IDs of vendors that have been chosen by the user regarding the legitimate interest Legal Basis. This takes into account the legitimate interest required purposes linked to vendors. When computing this property, essential purposes will be considered as enabled. |
vendors.consent.disabled | string[] | Disabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis. |
vendors.consent.enabled | string[] | Enabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis. |
vendors.legitimate_interest.disabled | string[] | Disabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis. |
vendors.legitimate_interest.enabled | string[] | Enabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis. |
user_id | String | Didomi user id. |
created | String | User choices creation date. |
updated | String | User choices update date. |
consent_string | String | TFC consent as string. |
additional_consent | String | Additional consent for Google Additional Consent Mode. |
Example
getUserStatusForVendor
Removed since version 2.0.0, use getUserStatus instead.
Search the vendorId in getUserStatus().vendors.global.enabled
or getUserStatus().vendors.global.disabled
.
getVendor
Get a vendor based on its ID.
Requires SDK to be initialized
Yes.
Parameters
Name | Type | Description |
---|---|---|
vendorId |
| ID of the vendor we want to get. |
Returns
Type | Description |
---|---|
| A |
Vendor
interface is defined in DidomiTypes.ts
Example
hideNotice
Hide the consent notice.
Parameters
No parameter.
Returns
Nothing
Example
hidePreferences
Hide the preferences popup.
Parameters
No parameter.
Returns
Nothing
Example
initialize
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).
Name | Type | Optional | Description |
---|---|---|---|
apiKey | string | No | Your API key |
localConfigurationPath | string | Yes | The path to your local config file in your |
remoteConfigurationPath | string | Yes | 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 |
providerId | string | Yes | 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 |
disableDidomiRemoteConfig | boolean | Yes | Prevent the SDK from loading a remote configuration from the Didomi Console. Defaults to Set this parameter to Set this parameter to |
languageCode | string | Yes | 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 e.g.: "es", "fr", etc. |
noticeId | string | Yes | 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. |
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
Promise<boolean>
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
Promise<boolean>
Example
isNoticeVisible
Check if the consent notice is currently displayed.
Parameters
No parameter.
Returns
Promise<boolean>
Example
isPreferencesVisible
Check if the preferences popup is currently displayed.
Parameters
No parameter.
Returns
Promise<boolean>
Example
isReady
Check if the SDK is ready.
Parameters
No parameter.
Returns
Promise<boolean>
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
Promise<boolean>
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
Type | Description |
---|---|
| 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
Type | Description |
---|---|
| A callback to run when the SDK is ready |
Returns
Nothing
Example
openCurrentUserStatusTransaction
Definition
Create a CurrentUserStatusTransaction
object.
This object 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 byCurrentUserStatusTransaction
should not update the status of any vendor or purpose which will always remain as enabled. When thecommit
method is called it will returnfalse
.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
AnCurrentUserStatusTransaction
object.
Description of a CurrentUserStatusTransaction
object
Method | Parameters | Returns | Description |
---|---|---|---|
|
| Current | Enable a single purpose based on its ID. |
|
| Current | Enable multiple purposes based on their IDs. |
|
| Current | Disable a single purpose based on its ID. |
|
| Current | Disable multiple purposes based on their IDs. |
|
| Current | Enable a single vendor based on its Didomi ID. |
|
| Current | Enable multiple vendors based on their Didomi IDs. |
|
| Current | Disable a single vendor based on its Didomi ID. |
|
| Current | Disable multiple vendors based on their Didomi IDs. |
| No parameters. |
| 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 number
argument which can have different values on Android and iOS platforms., for example:
iOS
Level | Value |
---|---|
| 1 |
| 2 |
| 16 |
| 17 |
Android
Level | Value |
---|---|
| 3 |
| 4 |
| 5 |
| 6 |
For more information see
Parameters
Name | Type | Description |
---|---|---|
level |
| Minimum level of messages to log. |
Returns
Nothing
Example
setupUI
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.
Returns
Nothing
Example
setUser
Set custom user information from organization
Parameters
Name
Name | Type | Description |
---|---|---|
organizationUserId |
| Organization ID to associate with the user |
Returns
Nothing
Example
setUser
Set custom user information from organization, with optional authentication parameters.
Name
Name | Type | Optional | Description |
---|---|---|---|
organizationUserId |
| No | Organization ID to associate with the user |
organizationUserIdAuthAlgorithm |
| Yes | Algorithm used for computing the digest |
organizationUserIdAuthSid |
| Yes | ID of the secret used for computing the digest |
organizationUserIdAuthSalt |
| Yes | Salt used for computing the digest (optional) |
organizationUserIdAuthDigest |
| Yes | Digest of the organization user ID and secret |
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 | |
---|---|
| Defines which view is displayed to the user first between the purposes view or the vendors view. Can be 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
Promise<boolean>
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
Promise<boolean>
true
if the user choices have changed (i.e. the user had made different choices before this function got called).
Example
setUserStatusSets
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
Name | Type | Description |
---|---|---|
enabledConsentPurposeIds |
| List of purpose IDs that the user has given consent to |
disabledConsentPurposeIds |
| List of purpose IDs that the user has not given consent to |
enabledLIPurposeIds |
| List of purpose IDs that the user has allowed legitimate interest processing to |
disabledLIPurposeIds |
| List of purpose IDs that the user has disallowed legitimate interest processing to |
enabledConsentVendorIds |
| List of vendor IDs that the user has given consent to. Prefix custom vendor IDs with |
disabledConsentVendorIds |
| List of vendor IDs that the user has not given consent to |
enabledLIVendorIds |
| List of vendor IDs that the user has allowed legitimate interest processing to. Prefix custom vendor IDs with |
disabledLIVendorIds |
| List of vendor IDs that the user has not allowed legitimate interest processing to |
Returns
Promise<boolean>
true
if the user choices have changed (i.e. the user had made different choices before this function got called).
Example
setUserStatus
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 |
|
|
purposesLIStatus |
|
|
vendorsConsentStatus |
|
|
vendorsLIStatus |
|
|
Returns
Promise<boolean>
true
if the user choices have changed (i.e. the user had made different choices before this function got called).
Example
shouldConsentBeCollected
Deprecated, use shouldUserStatusBeCollected instead.
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
Promise<boolean>
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
Promise<boolean>
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.
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 containing the 2-letter language code e.g. |
Returns
Nothing
Example
Last updated