Reference
This section is a comprehensive reference of the methods and events exposed by the Unity SDK that you can leverage in your application.
Always use Didomi.GetInstance()
to get a reference to the Didomi SDK. 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.
At the moment, on iOS, only one event listener is supported at the same time. If additional callbacks are required, they should be appended to the event handlers as in the example below.
Requires SDK to be initialized
No.
Parameters
eventListener
DidomiEventListener
The event listener. An instance or a subclass of DidomiEventListener
. Contains handlers for the different possible events.
Returns
Nothing
Example
Event types
The following events are supported by the Didomi SDK:
ConsentChangedEvent
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).
HideNoticeEvent
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.
ShowNoticeEvent
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.
NoticeClickAgreeEvent
When user clicks on agree on the notice
NoticeClickMoreInfoEvent
When user clicks on learn more on the notice
NoticeClickViewSPIPurposesEvent
When user clicks on "Limit the use of my personal information" on the notice
PreferencesClickAgreeToAllEvent
When user clicks on agree to all on the preferences popup
PreferencesClickDisagreeToAllEvent
When user clicks on disagree to all on the preferences popup
PreferencesClickPurposeAgreeEvent
When user agrees to a purpose on the preferences popup. (purposeId
provided as a parameter)
PreferencesClickPurposeDisagreeEvent
When user disagrees to a purpose on the preferences popup. (purposeId
provided as a parameter)
PreferencesClickCategoryAgreeEvent
When user agrees to a purposes category on the preferences popup. (categoryId
provided as a parameter)
PreferencesClickCategoryDisagreeEvent
When user disagrees to a purposes category on the preferences popup. (categoryId
provided as a parameter)
PreferencesClickViewSPIPurposesEvent
When user clicks on "Limit the use of my personal information" on the preferences popup
PreferencesClickViewVendorsEvent
When user clicks on view vendors on the preferences popup
PreferencesClickSaveChoicesEvent
When user saves his choice on the preferences popup
PreferencesClickSPIPurposeAgreeEvent
When user agrees to a purpose on the sensitive personal information screen. (purposeId
provided as a parameter)
PreferencesClickSPIPurposeDisagreeEvent
When user disagrees to a purpose on the sensitive personal information screen. (purposeId
provided as a parameter)
PreferencesClickSPICategoryAgreeEvent
When user agrees to a purposes category on the sensitive personal information screen. (categoryId
provided as a parameter)
PreferencesClickSPICategoryDisagreeEvent
When user disagrees to a purposes category on the sensitive personal information screen. (categoryId
provided as a parameter)
PreferencesClickSPIPurposeSaveChoicesEvent
When user saves his choice on the sensitive personal information screen
PreferencesClickVendorAgreeEvent
When user agrees to a vendor on the preferences popup. (vendorId
provided as a parameter)
PreferencesClickVendorDisagreeEvent
When user disagrees to a vendor on the preferences popup. (vendorId
provided as a parameter)
PreferencesClickVendorSaveChoicesEvent
When user saves his choice on the vendors view on the preferences popup
HidePreferencesEvent
When preferences screen is hidden
ShowPreferencesEvent
When preferences screen is shown
SyncReadyEvent
When synchronization is complete.
Provides the methods IsStatusApplied
and SyncAcknowledged
(see below)
SyncReadyEvent.StatusApplied
bool
indicating whether the user status was applied
SyncReadyEvent.SyncAcknowledged
Function that triggers a sync.acknowledged
API event when called. It returns true
if the API event was sent successfully.
SyncDoneEvent
Deprecated, use SyncReady
instead.
When synchronization is complete (synchronized organizationUserId
provided as parameter)
SyncErrorEvent
When synchronization encountered an error (errorMessage
provided as parameter)
LanguageUpdatedEvent
When selected language update was completed (selected languageCode
provided as parameter)
LanguageUpdateFailedEvent
When language selection update was not able to complete (reason
provided as parameter)
addVendorStatusListener
Listen for changes on the user status linked to a specific vendor.
At the moment, on iOS, only one listener per vendor is supported at the same time. If additional callbacks are required, they should be appended to the vendor status listener handler, as in the example below.
Requires SDK to be initialized
No.
Parameters
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.
vendorStatusListener
DidomiVendorStatusListener
An instance or a subclass of DidomiVendorStatusListener
. Contains a handler called when vendor status is changed.
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
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
DisableMockUI
Disable or enable the mock UI when testing in Unity Editor.
Android and iOS platform builds
This function has no effect for iOS or Android platform builds. It can safely be called in all environments and will only impact the Unity Editor.
Requires SDK to be initialized
No
Parameters
disable
boolean
true
to disable the mock UI
Returns
No return value
Example
GetDisabledPurposes
Deprecated, use GetUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetPurposes().GetConsent().GetDisabled()
.
Get the list of purposes that have been disabled by the user.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Purpose>
A set of type Purpose
containing the purposes disabled by the user.
Example
GetDisabledPurposeIds
Deprecated, use GetUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetPurposes().GetConsent().GetDisabled()
.
Get the list of purpose IDs that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<string>
A set of type string
containing the IDs of purposes disabled by the user.
Example
GetDisabledVendors
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetVendors().GetConsent().GetDisabled()
.
Get the list of vendors that have been disabled by the user.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Vendor>
An array of type Vendor
containing the vendors disabled by the user.
Example
GetDisabledVendorIds
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetVendors().GetConsent().GetDisabled()
.
Get the list of vendor IDs that have been disabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<string>
A set of type string
containing the IDs of vendors disabled by the user.
Example
GetEnabledPurposes
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetPurposes().GetGlobal().GetEnabled()
.
Get the list of purposes that have been enabled by the user.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Purpose>
An array of type Purpose
containing the purposes enabled by the user.
Example
GetEnabledPurposeIds
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetPurposes().GetGlobal().GetEnabled()
.
Get the list of purpose IDs that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<string>
A set of type string
containing the IDs of purposes enabled by the user.
Example
GetEnabledVendors
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetVendors().GetConsent().GetEnabled()
Get the list of vendors that have been enabled by the user.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Vendor>
A set of type Vendor
containing the vendors enabled by the user.
Example
GetEnabledVendorIds
Deprecated, use getUserStatus instead.
The result of this method has been replaced by GetUserStatus().GetVendors().GetConsent().GetEnabled()
Get the list of vendor IDs that have been enabled by the user.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<string>
A set of type string
containing the IDs of vendors enabled by the user.
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
string
JavaScript code to embed in a WebView
Example
GetPurpose
Get a purpose based on its ID.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
purposeId
string
ID of the purpose we want to get.
Returns
Purpose
A Purpose
with ID purposeId
found in the array of required purposes.
Example
GetRequiredPurposes
Get the list of purpose that are required (automatically determined from the list of required vendors).
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Purpose>
A set 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
ISet<string>
A set of type string
containing the IDs of required purposes.
Example
GetRequiredVendors
Get the list of vendors that are required (determined from the configuration).
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
ISet<Vendor>
A set 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
ISet<string>
A set of type string
containing the IDs of required vendors.
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
key
string
key associated to the dictionary that we want to get.
Returns
IDictionary<string,string>
Dictionary 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:
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/customize-the-theme#translatable-texts-for-custom-notices
Requires SDK to be initialized
Yes.
Parameters
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().GetPurposes().GetConsent().GetEnabled()
or GetUserStatus().GetPurposes().GetConsent().GetDisabled()
.
Get the user consent status for a given purpose. You must also check that the user has given consent to a vendor specifically before being able to load a vendor.
Requires SDK to be initialized
Yes.
Parameters
purposeId
string
The ID of the purpose to check the user consent for.
Returns
A ConsentStatus
object that indicates if the user has given consent or not to the specific purpose.
ConsentStatus.enable
is returned if the user has given consent to the purpose. ConsentStatus.disable
is returned if the user has denied consent.
ConsentStatus.unknown
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable
(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 the consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable
.
Example
GetUserConsentStatusForVendor
Deprecated, use GetUserStatus instead.
Search the purposeId in GetUserStatus().GetVendors().GetConsent().GetEnabled()
or GetUserStatus().GetVendors().GetConsent().GetDisabled()
.
Get the user consent status for a given vendor. You must also check that the user has given consent to some or all of the purposes required by a vendor before loading the vendor.
The function getUserConsentStatusForVendorAndRequiredPurposes
does all the required checks for you so it might be a better choice.
Requires SDK to be initialized
Yes.
Parameters
vendorId
string
The ID of the vendor to check the user consent for.
If you are checking an IAB vendor, pass the number as a string.
If you are checking a custom vendor, prefix your vendor ID with c:
.
Returns
A ConsentStatus
object that indicates if the user has given consent or not to the specific vendor.
ConsentStatus.enable
is returned if the user has given consent. ConsentStatus.disable
is returned if the user has denied consent.
ConsentStatus.unknown
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable
(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 the consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable
.
In Objective-C, the return value is an Int and not an Enum. It can take one of the following values:
ConsentStatusEnable
ConsentStatusDisable
ConsentStatusUnknown
Example
GetUserConsentStatusForVendorAndRequiredPurposes
Deprecated, use GetUserStatus instead.
Search the purposeId in GetUserStatus().GetVendors().GetGlobalConsent().GetEnabled()
or GetUserStatus().GetVendors().GetGlobalConsent().GetDisabled()
.
Get the user consent status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.
Requires SDK to be initialized
Yes.
Parameters
vendorId
string
The ID of the vendor to check the user consent for.
If you are checking an IAB vendor, pass the number as a string.
If you are checking a custom vendor, prefix your vendor ID with c:
.
Returns
A ConsentStatus
object that indicates if the user has given consent or not to the specific vendor and all its required purposes.
ConsentStatus.enable
is returned if the user has given consent. ConsentStatus.disable
is returned if the user has denied consent.
ConsentStatus.unknown
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat it as ConsentStatus.disable
(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 the consent information to be collected.
If consent is not required because GDPR does not apply to that user, this function will return ConsentStatus.enable
.
In Objective-C, the return value is an Int and not an Enum. It can take one of the following values:
ConsentStatusEnable
ConsentStatusDisable
ConsentStatusUnknown
Example
GetUserStatus
Get all the user consent status.
Returns
A UserStatus
object describing all the available and computed user information.
purposes.global.disabled
ISet<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
ISet<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
ISet<string>
Disabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.
purposes.consent.enabled
ISet<string>
Enabled IDs of purposes that have been explicitly chosen by the user regarding the consent Legal Basis.
purposes.legitimateInterest.disabled
ISet<string>
Disabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
purposes.legitimateInterest.enabled
ISet<string>
Enabled IDs of purposes that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
purposes.essential
ISet<string>
IDs of purposes that are considered essential.
vendors.global.disabled
ISet<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
ISet<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.globalConsent.disabled
ISet<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.globalConsent.enabled
ISet<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.globalLegitimateInterest.disabled
ISet<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.globalLegitimateInterest.enabled
ISet<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
ISet<string>
Disabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.
vendors.consent.enabled
ISet<string>
Enabled IDs of vendors that have been explicitly chosen by the user regarding the consent Legal Basis.
vendors.legitimateInterest.disabled
ISet<string>
Disabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
vendors.legitimateInterest.enabled
ISet<string>
Enabled IDs of vendors that have been explicitly chosen by the user regarding the legitimate interest Legal Basis.
userId
string
Didomi user id.
created
string
User choices creation date.
updated
string
User choices update date.
consentString
string
TFC consent as string.
additionalConsent
string
Example
GetVendor
Get a vendor based on its ID.
Not available for IOS platform builds
This function is only exposed to Unity Android platform builds. It cannot be called from Unity IOS platform builds.
Requires SDK to be initialized
Yes.
Parameters
vendorId
string
ID of the vendor we want to get.
Returns
Vendor
A Vendor
with ID vendorId
found in the array of required vendors.
Example
HideNotice
Hide the consent notice.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Nothing
Example
HidePreferences
Hide the preferences popup.
Requires SDK to be initialized
Yes.
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
Name
Type
Description
initializeParameters
DidomiInitializeParameters
Object containing the application parameters, see below
The DidomiInitializeParameters object contains all the information needed to initialize the SDK.
The parameter disableDidomiRemoteConfig
is deprecated, we strongly suggest you to create your notice from the console (see Setup from the Console for more information).
apiKey
string
No
Your API key
localConfigurationPath
string
Yes
The path to your local config file in your assets/
folder. Defaults to didomi_config.json
if null.
remoteConfigurationURL
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 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
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 null
.
disableDidomiRemoteConfig (deprecated)
bool
Yes
Prevent the SDK from loading a remote configuration from the Didomi Console. Defaults to false
(allows 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
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"
, "en-US"
, "zh-HK"
, 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.
tvNoticeId (only used on Android TV
string
Yes
TV notice ID to load the configuration from. If provided and SDK is initialized on Android TV, the SDK bypasses the app ID targeting and directly loads the configuration from the notice ID.
androidTvEnabled (only used on Android TV)
bool
Yes
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
Yes
Override user country code when determining the privacy regulation to apply.
Keep null
to let the Didomi SDK determine the user country.
regionCode
string
Yes
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.
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.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
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.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
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
bool
Example
IsNoticeVisible
Check if the consent notice is currently displayed.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
bool
Example
IsPreferencesVisible
Check if the preferences popup is currently displayed.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
bool
Example
IsReady
Check if the SDK is ready.
Requires SDK to be initialized
No.
Parameters
No parameter.
Returns
bool
Example
OnReady
Add an event listener that will be called when the SDK is ready (ie fully initialized). If the event listener is added after the SDK initialization, the listener will be called immediately.
All calls to other functions of this API must only be made in a listener to the ready event to make sure that the SDK is initialized before it is used.
Requires SDK to be initialized
No.
Parameters
callback
Action
An action to call when the SDK is ready
Returns
Nothing
Example
OnError
Add an event listener that will be called when the SDK initialization encounters an error or if an unexpected situation occurs. Note that the behavior of the callback may slightly differ between Android and iOS platforms.
Requires SDK to be initialized
No.
Parameters
callback
Action
An action to call when the SDK encounters an error
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 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
An instance of the CurrentUserStatusTransaction
class.
Description of the CurrentUserStatusTransaction
class
EnablePurpose
id
(string
): ID of the purpose to be enabled.
Current CurrentUserStatusTransaction
object.
Enable a single purpose based on its ID.
EnablePurposes
ids
(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
(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
(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
(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
SetupUI
Internally, the setupUI method calls the showNotice
method, which calls the shouldUserStatusBeCollected
method. Therefore, by calling the setupUI
method, the notice or preferences view will be displayed only if required.
Setup the SDK UI workflows. By calling this method the notice or the preferences views will be displayed only once the SDK is ready and if consent should be collected.
For IOS platformsUIViewController
returned by UnityGetGLViewController at Unity is used as base UI. For Android platforms Activity
returned by com.unity3d.player.UnityPlayer.currentActivity is used as base UI.
Requires SDK to be initialized
No.
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 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).
Requires SDK to be initialized
Yes.
Parameters
No parameter.
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 can be used to allow the user to update their preferences after the banner has been closed. We suggest adding a link with this function call somewhere in your app.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
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.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
Nothing
Example
SetUser
Parameters
Method without authentication:
organizationUserId
String
Organization ID to associate with the user
Method with Encrypted authentication:
userAuthParams
UserAuthWithEncryptionParams
User authentication with Encryption
Parameters for UserAuthWithEncryptionParams
:
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?
Expiration time as UNIX timestamp (optional - must be > 0)
Method with Hash authentication:
userAuthParams
UserAuthWithHashParams
User authentication with Hash
Parameters for UserAuthWithHashParams
:
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
Salt used for computing the user ID (optional)
expiration
long?
Expiration time as UNIX timestamp (optional - must be > 0)
Returns
Nothing
Example
SetUserAndSetupUI
Set custom user information from organization, and call SetupUI
after synchronization if sdk was initialized
Parameters
See SetUser
Returns
Nothing
Example
ClearUser
Remove custom user information from organization
Requires SDK to be initialized
No.
Parameters
No parameter.
Returns
Nothing
Example
SetUserAgreeToAll
Report that the user has given consent to all purposes and vendors setup for your app programmatically. This function will log the consent on our platform and close the notice.
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Requires SDK to be initialized
Yes.
Parameters
No parameter.
Returns
bool
true
if the user consent status has changed (ie the user had given different consent information before this function got called).
Example
SetUserConsentStatus
Set the user consent 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 your consent information 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.
Requires SDK to be initialized
Yes.
Parameters
enabledPurposeIds
ISet<string>
Set of purpose IDs that the user has given consent to
disabledPurposeIds
ISet<string>
Set of purpose IDs that the user has not given consent to
enabledVendorIds
ISet<string>
Set of vendor IDs that the user has given consent to
disabledVendorIds
ISet<string>
Set of vendor IDs that the user has not given consent to
Returns
bool
true
if the user consent status has changed (ie the user had given different consent information before this function got called).
Example