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

Returns

Nothing

Example

   
    private void RegisterEventHandlers()
    {
        DidomiEventListener eventListener = new DidomiEventListener();
        eventListener.ConsentChanged += EventListener_ConsentChanged;
        eventListener.Ready += EventListener_Ready;
        eventListener.ShowNotice += EventListener_ShowNotice;
        eventListener.HideNotice += EventListener_HideNotice;
        eventListener.NoticeClickAgree += EventListener_NoticeClickAgree;
        eventListener.NoticeClickMoreInfo += EventListener_NoticeClickMoreInfo;
        eventListener.NoticeClickViewSPIPurposes += EventListener_NoticeClickViewSPIPurposes;
        eventListener.PreferencesClickAgreeToAll += EventListener_PreferencesClickAgreeToAll;
        eventListener.PreferencesClickDisagreeToAll += EventListener_PreferencesClickDisagreeToAll;
        eventListener.PreferencesClickViewVendors += EventListener_PreferencesClickViewVendors;
        eventListener.PreferencesClickViewSPIPurposes += EventListener_PreferencesClickViewSPIPurposes;
        eventListener.PreferencesClickSaveChoices += EventListener_PreferencesClickSaveChoices;
        eventListener.PreferencesClickPurposeAgree += EventListener_PreferencesClickPurposeAgree;
        eventListener.PreferencesClickPurposeDisagree += EventListener_PreferencesClickPurposeDisagree;
        eventListener.PreferencesClickCategoryAgree += EventListener_PreferencesClickCategoryAgree;
        eventListener.PreferencesClickCategoryDisagree += EventListener_PreferencesClickCategoryDisagree;
        eventListener.PreferencesClickSPIPurposeAgree += EventListener_PreferencesClickSPIPurposeAgree;
        eventListener.PreferencesClickSPIPurposeDisagree += EventListener_PreferencesClickSPIPurposeDisagree;
        eventListener.PreferencesClickSPICategoryAgree += EventListener_PreferencesClickSPICategoryAgree;
        eventListener.PreferencesClickSPICategoryDisagree += EventListener_PreferencesClickSPICategoryDisagree;
        eventListener.PreferencesClickSPIPurposeSaveChoices += EventListener_PreferencesClickSPIPurposeSaveChoices;
        eventListener.PreferencesClickVendorAgree += EventListener_PreferencesClickVendorAgree;
        eventListener.PreferencesClickVendorDisagree += EventListener_PreferencesClickVendorDisagree;
        eventListener.PreferencesClickVendorSaveChoices += EventListener_PreferencesClickVendorSaveChoices;
        eventListener.HidePreferences += EventListener_HidePreferences;
        eventListener.ShowPreferences += EventListener_ShowPreferences;
        eventListener.SyncDone += EventListener_SyncDone;
        eventListener.SyncError += EventListener_SyncError;
        eventListener.LanguageUpdated += EventListener_LanguageUpdated;
        eventListener.LanguageUpdateFailed += EventListener_LanguageUpdateFailed;

        Didomi.GetInstance().AddEventListener(eventListener);
    }

    private void EventListener_ConsentChanged(object sender, ConsentChangedEvent e)
    {
        // The consent status of the user has changed
    }
    
    private void EventListener_Ready(object sender, ReadyEvent e)
    {
        // The Didomi SDK is ready
    }

    private void EventListener_ShowNotice(object sender, ShowNoticeEvent e)
    {
        // The notice is being shown or needs to be shown
    }
    
   private void EventListener_HideNotice(object sender, HideNoticeEvent e)
    {
        // The notice is being hidden
    }
    
    private void EventListener_NoticeClickAgree(object sender, NoticeClickAgreeEvent e)
    {
        // Click on agree on notice
    }

    private void EventListener_NoticeClickMoreInfo(object sender, NoticeClickMoreInfoEvent e)
    {
        // Click on learn more on notice
    }
    
    private void EventListener_NoticeClickViewSPIPurposes(object sender, NoticeClickViewSPIPurposesEvent e)
    {
        // Click on "Limit the use of my Sensitive Personal Information" on notice
    }
    
    private void EventListener_PreferencesClickAgreeToAll(object sender, PreferencesClickAgreeToAllEvent e)
    {
        // Click on agree to all on preferences popup
    }
    
    private void EventListener_PreferencesClickDisagreeToAll(object sender, PreferencesClickDisagreeToAllEvent e)
    {
        // Click on disagree to all on preferences popup
    }
  
    private void EventListener_PreferencesClickViewSPIPurposes(object sender, PreferencesClickViewSPIPurposesEvent e)
    {
        // Click on "Limit the use of my Sensitive Personal Information" on preferences screen
    }
      
    private void EventListener_PreferencesClickViewVendors(object sender, PreferencesClickViewVendorsEvent e)
    {
        // Click view vendors on purposes view on preferences popup
    }
    
    private void EventListener_PreferencesClickSaveChoices(object sender, PreferencesClickSaveChoicesEvent e)
    {
        // Click on save on the purposes view on preferences popup
    }
    
    private void EventListener_PreferencesClickPurposeAgree(object sender, PreferencesClickPurposeAgreeEvent e)
    {
        // Click on agree to a purpose on preferences popup
    }
    
    private void EventListener_PreferencesClickPurposeDisagree(object sender, PreferencesClickPurposeDisagreeEvent e)
    {
        // Click on disagree to a purpose on preferences popup
    }
    
    private void EventListener_PreferencesClickCategoryAgree(object sender, PreferencesClickCategoryAgreeEvent e)
    {
        // Click on agree to a purposes category on preferences popup
    }
    
    private void EventListener_PreferencesClickCategoryDisagree(object sender, PreferencesClickCategoryDisagreeEvent e)
    {
        // Click on disagree to a purposes category on preferences popup
    }
    
    private void EventListener_PreferencesClickSPIPurposeAgree(object sender, PreferencesClickSPIPurposeAgreeEvent e)
    {
        // Click on agree to a purpose on sensitive personal information screen
    }
    
    private void EventListener_PreferencesClickSPIPurposeDisagree(object sender, PreferencesClickSPIPurposeDisagreeEvent e)
    {
        // Click on disagree to a purpose on sensitive personal information screen
    }
    
    private void EventListener_PreferencesClickSPICategoryAgree(object sender, PreferencesClickSPICategoryAgreeEvent e)
    {
        // Click on agree to a purposes category on sensitive personal information screen
    }
    
    private void EventListener_PreferencesClickCategoryDisagree(object sender, PreferencesClickSPICategoryDisagreeEvent e)
    {
        // Click on disagree to a purposes category on sensitive personal information screen
    }
    
    private void EventListener_PreferencesClickSPIPurposeSaveChoices(object sender, PreferencesClickSPIPurposeSaveChoicesEvent e)
    {
        // Click on save on the sensitive personal information screen
    }

    private void EventListener_PreferencesClickVendorAgree(object sender, PreferencesClickVendorAgreeEvent e)
    {
        // Click on agree to a vendor on preferences popup
    }

    private void EventListener_PreferencesClickVendorDisagree(object sender, PreferencesClickVendorDisagreeEvent e)
    {
        // Click on disagree to a vendor on preferences popup
    }
    
    private void EventListener_PreferencesClickVendorSaveChoices(object sender, PreferencesClickVendorSaveChoicesEvent e)
    {
        // Click on save on the vendors view on preferences popup
    }
    
    private void EventListener_ShowPreferences(object sender, ShowPreferencesEvent e)
    {
        // The preferences screen is being shown
    }
    
    private void EventListener_HidePreferences(object sender, HidePreferencesEvent e)
    {
        // The preferences screen is being hidden
    }
    
    private void EventListener_SyncDone(object sender, SyncDoneEvent e)
    {
        // Synchronization was done successfully
    }
    
    private void EventListener_SyncError(object sender, SyncErrorEvent e)
    {
        // An error occurred during synchronization
    }
    
    private void EventListener_LanguageUpdated(object sender, LanguageUpdatedEvent e)
    {
        // Language update was completed
    }
    
    private void EventListener_LanguageUpdateFailed(object sender, LanguageUpdateFailedEvent e)
    {
        // Language update was not completed
    }

    

Event types

The following events are supported by the Didomi SDK:

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

Returns

Nothing

Example

private void RegisterVendorStatusListener()
{
    DidomiVendorStatusListener vendorStatusListener = new DidomiVendorStatusListener();
    vendorStatusListener.VendorStatusChanged += VendorStatusListener_VendorStatusChanged;
    Didomi.GetInstance().AddVendorStatusListener("vendor1", vendorStatusListener);
}

private void VendorStatusListener_VendorStatusChanged(object sender, CurrentUserStatus.VendorStatus status)
{
    Debug.Log(status.Id + "status has changed: " + status.Enabled);
}

removeVendorStatusListener

Stop listening for changes on the user status linked to a specific vendor.

Requires SDK to be initialized

No.

Parameters

Returns

Nothing

Example

Didomi.GetInstance().RemoveVendorStatusListener("vendor1");

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

Returns

No return value

Example

Didomi.GetInstance().DisableMockUI(true);

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

Example

Didomi.GetInstance().GetDisabledPurposes();

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

Example

Didomi.GetInstance().GetDisabledPurposeIds();

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

Example

Didomi.GetInstance().GetDisabledVendors();

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

Example

Didomi.GetInstance().GetDisabledVendorIds();

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

Example

Didomi.GetInstance().GetEnabledPurposes();

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

Example

Didomi.GetInstance().GetEnabledPurposeIds();

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

Example

Didomi.GetInstance().GetEnabledVendors();

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

Example

Didomi.GetInstance().GetEnabledVendorIds();

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

Example

Didomi.GetInstance().GetJavaScriptForWebView();

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

Returns

Example

Didomi.GetInstance().GetPurpose("purpose-id");

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

Example

Didomi.GetInstance().GetRequiredPurposes();

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

Example

Didomi.GetInstance().GetRequiredPurposeIds();

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

Example

Didomi.GetInstance().GetRequiredVendors();

GetRequiredVendorIds

Get the list of vendor IDs that are required (determined from the configuration).

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Example

Didomi.GetInstance().GetRequiredVendorIds();

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

Returns

Example

Didomi.GetInstance().GetText("key");

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:

Requires SDK to be initialized

Yes.

Parameters

Returns

Translated text.

Example

Didomi.GetInstance().GetTranslatedText("key");

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

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

Didomi.GetInstance().GetUserConsentStatusForPurpose("purpose-id");

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

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

// IAB vendors
Didomi.GetInstance().GetUserConsentStatusForVendor("1");

// Didomi vendors
Didomi.GetInstance().GetUserConsentStatusForVendor("google");

// Custom vendors
Didomi.GetInstance().GetUserConsentStatusForVendor("c:custom-vendor-id");

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

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

// IAB vendors
Didomi.GetInstance().GetUserConsentStatusForVendorAndRequiredPurposes("1");

// Didomi vendors
Didomi.GetInstance().GetUserConsentStatusForVendorAndRequiredPurposes("google");

// Custom vendors
Didomi.GetInstance().GetUserConsentStatusForVendorAndRequiredPurposes("c:custom-vendor-id");

GetUserStatus

Get all the user consent status.

Returns

A UserStatus object describing all the available and computed user information.

Example

UserStatus userStatus = Didomi.GetInstance().GetUserStatus();

// Example: Enabled consent ids for vendors
ISet<string> enabledVendorsConsentIds = userStatus.GetVendors().GetConsent().GetEnabled();

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

Returns

Example

Didomi.GetInstance().GetVendor("vendor-id");

HideNotice

Hide the consent notice.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Didomi.GetInstance().HideNotice();

HidePreferences

Hide the preferences popup.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

Nothing

Example

Didomi.GetInstance().HidePreferences();

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 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).

Returns

Nothing

Example

 Didomi.GetInstance().Initialize(
     new DidomiInitializeParameters(
          apiKey: "<Your API key>",
          localConfigurationPath: null,
          remoteConfigurationURL: null,
          providerId: null,
          disableDidomiRemoteConfig: false,
          languageCode: null,
          noticeId: "<Your notice Id>",
          tvNoticeId: null,
          androidTvEnabled: false
));

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

Didomi.GetInstance().IsConsentRequired();

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

Didomi.GetInstance().IsUserConsentStatusPartial();

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

Didomi.GetInstance().IsUserStatusPartial();

IsNoticeVisible

Check if the consent notice is currently displayed.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

bool

Example

Didomi.GetInstance().IsNoticeVisible();

IsPreferencesVisible

Check if the preferences popup is currently displayed.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

bool

Example

Didomi.GetInstance().IsPreferencesVisible();

IsReady

Check if the SDK is ready.

Requires SDK to be initialized

No.

Parameters

No parameter.

Returns

bool

Example

Didomi.GetInstance().IsReady();

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

Returns

Nothing

Example

Didomi.GetInstance().OnReady( () => {
     // The SDK is ready 
});

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

Returns

Nothing

Example

Didomi.GetInstance().OnError( () => {
     // The SDK encountered an error 
});

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 the CurrentUserStatusTransaction class

Examples

var transaction = Didomi.GetInstance().OpenCurrentUserStatusTransaction();

// Enable a purpose
transaction.EnablePurpose("cookies");
// Enable purposes
transaction.EnablePurposes("cookies", "analytics");
// Disable a purpose
transaction.DisablePurpose("analytics");
// Disable purposes
transaction.DisablePurposes("cookies", "analytics");
// Enable a vendor
transaction.EnableVendor("vendor-1");
// Enable vendors
transaction.EnableVendors("vendor-1", "vendor-2");
// Disable a vendor
transaction.DisableVendor("vendor-1");
// Disable vendors
transaction.DisableVendors("vendor-1", "vendor-2");

// Chain multiple calls
transaction.EnablePurpose("cookies").DisablePurpose("analytics");

// Save user choices
var updated = transaction.Commit();

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

Didomi.GetInstance().SetupUI();

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

Didomi.GetInstance().ShowNotice();

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

Didomi.GetInstance().ShowPreferences();

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

Didomi.GetInstance().Reset();

SetUser

Parameters

Method without authentication:

Method with Encrypted authentication:

Parameters for UserAuthWithEncryptionParams :

Method with Hash authentication:

Parameters for UserAuthWithHashParams :

Returns

Nothing

Example

Didomi.GetInstance().SetUser("e3222031-7c45-4f4a-8851-ffd57dbf0a2a");

Didomi.GetInstance().SetUser(new UserAuthWithEncryptionParams(
            "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
            "algorithm",
            "secret_id",
            "initialization_vector",
            10000L // or null
));

Didomi.GetInstance().SetUser(new UserAuthWithHashParams(
            "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
            "algorithm",
            "secret_id",
            "digest",
            "salt", // or null
            10000L // or null
)); 

SetUserAndSetupUI

Set custom user information from organization, and call SetupUI after synchronization if sdk was initialized

Parameters

See SetUser

Returns

Nothing

Example

Didomi.GetInstance().SetUserAndSetupUI("e3222031-7c45-4f4a-8851-ffd57dbf0a2a");

Didomi.GetInstance().SetUserAndSetupUI(new UserAuthWithEncryptionParams(
            "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
            "algorithm",
            "secret_id",
            "initialization_vector",
            10000L // or null
));

Didomi.GetInstance().SetUserAndSetupUI(new UserAuthWithHashParams(
            "e3222031-7c45-4f4a-8851-ffd57dbf0a2a",
            "algorithm",
            "secret_id",
            "digest",
            "salt", // or null
            10000L // or null
)); 

ClearUser

Remove custom user information from organization

Requires SDK to be initialized

No.

Parameters

No parameter.

Returns

Nothing

Example

Didomi.GetInstance().ClearUser();

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

Didomi.GetInstance().SetUserAgreeToAll();

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

Returns

bool

true if the user consent status has changed (ie the user had given different consent information before this function got called).

Example

var enabledPurposeIds = new string[] { "1", "2" };
var disabledPurposeIds= new string[] { "3", "4" };
var enabledVendorIds= new string[] { "1", "2" };
var disabledVendorIds= new string[] { ""3", "4" };

Didomi.GetInstance().SetUserConsentStatus(
                enabledPurposeIds,
                disabledPurposeIds,
                enabledVendorIds,
                disabledVendorIds);

SetUserDisagreeToAll

Report that the user has denied consent to all purposes and vendors setup for your app programmatically. This function will log the consent information on our platform and close the banner.

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

Didomi.GetInstance().SetUserDisagreeToAll();

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.

Requires SDK to be initialized

Yes.

Parameters

No parameter.

Returns

bool

Example

Didomi.GetInstance().ShouldConsentBeCollected();

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

bool

Example

Didomi.GetInstance().ShouldUserStatusBeCollected();

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.

The language update is performed asynchronously. If you need to make sure the update is done, you can listen to the events LanguageUpdated / LanguageUpdateFailed.

Requires SDK to be initialized

Yes.

Parameters

Returns

Nothing

Example

Didomi.GetInstance().OnReady( () => {
     // The SDK is ready 
     Didomi.GetInstance().UpdateSelectedLanguage("en");
});           

Last updated