Events

The Didomi SDK triggers various events to notify you that the user has taken some action (changed their consent status, opened the preferences screen, etc.) or that an important event has happened.

This section describes what events are available and how to subscribe to them.

addEventListener

This method adds 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.

Parameters

Name
Type
Description

eventListener

EventListener

The event listener. An instance of a subclass of io.didomi.sdk.events.EventListener

Returns

Nothing

Example

import io.didomi.sdk.events.EventListener;
import io.didomi.sdk.events.ConsentChangedEvent;

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // React to consent changed
    }
    
    @Override
    public void showNotice(ShowNoticeEvent event) {
        // React to notice being shown
    }
});

Event types

This section presents a comprehensive list of the event types exposed by the Didomi SDK and usage examples.

consentChanged

Triggered when the user consent status changes, either as the result of a user action or an API call.

Listener parameters

ConsentChangedEvent object (contains no properties)

Example

error

Triggered when an unexpected situation occurs, for example an error during the initialization process.

Listener parameters

ErrorEvent object with the following properties:

Name
Type
Description

errorMessage

String

String describing the reason of the error.

errorType

ErrorType (enum)

One of the following values:

NULL_PROPERTY, CONFIG_FILE_ERROR, INVALID_API_KEY, INITIALIZATION_ERROR, WEB_SDK_ERROR or ERROR_LOADING_UI_RESOURCE.

Example

hideNotice

Triggered when the user closes the consent notice. 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.

Listener parameters

HideNoticeEvent object (contains no properties)

Example

showNotice

Triggered when the consent notice gets shown to the user. 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.

Listener parameters

ShowNoticeEvent object (contains no properties)

Example

noticeClickAgree

Triggered when the user clicks on the Agree and close button of a consent notice.

Listener parameters

NoticeClickAgreeEvent object (contains no properties)

Example

noticeClickDisagree

Triggered when the user clicks on the Decline button of a consent notice.

Listener parameters

NoticeClickDisagreeEvent object (contains no properties)

Example

noticeClickMoreInfo

Triggered when the user clicks on the Learn More button of a consent notice.

Listener parameters

NoticeClickMoreInfoEvent object (contains no properties)

Example

noticeClickViewVendors

Triggered when the user clicks on the partners link/button of a consent notice.

Listener parameters

NoticeClickViewVendorsEvent object (contains no properties)

Example

noticeClickViewSPIPurposes

Triggered when the user clicks on the Sensitive Personal Information button of a consent notice.

Listener parameters

NoticeClickViewSPIPurposesEvent object (contains no properties)

Example

noticeClickPrivacyPolicy

Triggered when the user clicks on the privacy policy button of a consent notice (available on TV only)

Listener parameters

NoticeClickPrivacyPolicyEvent object (contains no properties)

Example

hidePreferences

Triggered when the preferences screen becomes hidden, for example when the user closed it or saved their consent.

Listener parameters

HidePreferencesEvent object (contains no properties)

Example

showPreferences

Triggered when the preferences screen gets displayed.

Listener parameters

ShowPreferencesEvent object (contains no properties)

Example

preferencesClickAgreeToAll

Triggered when the user clicks on the Agree to all button of the preferences screen.

Listener parameters

PreferencesClickAgreeToAllEvent object (contains no properties)

Example

preferencesClickDisagreeToAll

Triggered when the user clicks on the Disagree to all button of the preferences screen.

Listener parameters

PreferencesClickDisagreeToAllEvent object (contains no properties)

Example

preferencesClickSaveChoices

Triggered when the user clicks on the Save button of the preferences screen.

Listener parameters

PreferencesClickSaveChoicesEvent object (contains no properties)

Example

preferencesClickPurposeAgree

Triggered when the user agrees to an individual purpose on the preferences screen.

Listener parameters

PreferencesClickPurposeAgreeEvent object with the following property:

Method

Type

Description

purposeId

String

Unique ID of the purpose that was enabled

Example

preferencesClickPurposeDisagree

Triggered when the user disagrees to an individual purpose on the preferences screen.

Listener parameters

PreferencesClickPurposeDisagreeEvent object with the following property:

Method
Type
Description

purposeId

String

Unique ID of the purpose that was disabled

Example

preferencesClickCategoryAgree

Triggered when the user agrees to a purposes category on the preferences screen.

Listener parameters

PreferencesClickCategoryAgreeEvent object with the following property:

Method
Type
Description

categoryId

String

Unique ID of the category that was enabled

Example

preferencesClickCategoryDisagree

Triggered when the user disagrees to a purposes category on the preferences screen.

Listener parameters

PreferencesClickCategoryDisagreeEvent object with the following property:

Method
Type
Description

categoryId

String

Unique ID of the category that was disabled

Example

preferencesClickViewVendors

Triggered when the user clicks on View Vendors buttons on the preferences screen.

Listener parameters

PreferencesClickViewVendorsEvent object (contains no properties)

preferencesClickViewSPIPurposes

Triggered when the user clicks on Sensitive Personal Information button from preferences screen.

Listener parameters

PreferencesClickViewSPIPurposesEvent object (contains no property)

Example

preferencesClickVendorAgree

Triggered when the user agrees to an individual vendor on the preferences screen.

Listener parameters

PreferencesClickVendorAgreeEvent object with the following property:

Method
Type
Description

vendorId

String

Unique ID of the vendor that was enabled

Example

preferencesClickVendorDisagree

Triggered when the user disagrees to an individual vendor on the preferences screen.

Listener parameters

PreferencesClickVendorDisagreeEvent object with the following property:

Method
Type
Description

vendorId

String

Unique ID of the vendor that was disabled

Example

preferencesClickAgreeToAllVendors

Triggered when the user agrees to all the vendors through the global switch on the preferences screen.

Listener parameters

PreferencesClickAgreeToAllVendorsEvent object (contains no property)

Example

preferencesClickDisagreeToAllVendors

Triggered when the user disagrees to all the vendors through the global switch on the preferences screen.

Listener parameters

PreferencesClickDisagreeToAllVendorsEvent object (contains no property)

Example

preferencesClickVendorSaveChoices

Triggered when the user clicks on Save button on the vendors view on preferences screen.

Listener parameters

PreferencesClickVendorSaveChoicesEvent object (contains no property)

Example

preferencesClickViewPurposes

Triggered when the user clicks on View Purpose button from preferences screen (available only on TV).

Listener parameters

PreferencesClickViewPurposesEvent object (contains no property)

Example

preferencesClickAgreeToAllPurposes

Triggered when the user agrees to all the purposes through the global switch on the preferences screen.

Listener parameters

PreferencesClickAgreeToAllPurposesEvent object (contains no property)

Example

preferencesClickDisagreeToAllPurposes

Triggered when the user disagrees to all the purposes through the global switch on the preferences screen.

Listener parameters

PreferencesClickDisagreeToAllPurposesEvent object (contains no property)

Example

preferencesClickSPIPurposeAgree

Triggered when the user agrees to an individual Personal Data purpose from the preferences screen.

Listener parameters

PreferencesClickSPIPurposeAgreeEvent object with the following property:

Method

Type

Description

purposeId

String

Unique ID of the purpose that was enabled

Example

preferencesClickSPIPurposeDisagree

Triggered when the user disagrees to an individual Personal Data purpose from the preferences screen.

Listener parameters

PreferencesClickSPIPurposeDisagreeEvent object with the following property:

Method
Type
Description

purposeId

String

Unique ID of the purpose that was disabled

Example

preferencesClickSPICategoryAgree

Triggered when the user agrees to a Personal Data category from the preferences screen.

Listener parameters

PreferencesClickSPICategoryAgreeEvent object with the following property:

Method
Type
Description

categoryId

String

Unique ID of the category that was enabled

Example

preferencesClickSPICategoryDisagree

Triggered when the user disagrees to a Personal Data category from the preferences screen.

Listener parameters

PreferencesClickSPICategoryDisagreeEvent object with the following property:

Method
Type
Description

categoryId

String

Unique ID of the category that was disabled

Example

preferencesClickSPIPurposeSaveChoices

Triggered when the user clicks on Save button from the Sensitive Personal Information view from preferences screen.

Listener parameters

PreferencesClickSPIPurposeSaveChoicesEvent object (contains no property)

Example

syncUserChanged

Triggered when the user is changed from setUser function only if sync is enabled.

Listener parameters

SyncUserChangedEvent object with the following property:

Method

Type

Description

userAuth

UserAuth

The new user as UserAuthWithoutParams, UserAuthWithEncryptionParams or UserAuthWithHashParams

Example

syncDone

Triggered when the consent synchronization is successful (Cross-device).

Listener parameters

SyncDoneEvent object (contains no property)

Example

syncError

Triggered when the consent synchronization has failed (Cross-device).

Listener parameters

SyncErrorEvent object (contains no property)

Example

syncReady

Triggered when the user status synchronization is ready (cross-device).

Listener parameters

SyncReadyEvent object

Property
Type
Description

organizationUserId

String

The organization user ID (OUID) used for the sync.

statusApplied

Boolean

Indicates if the user status has been applied locally from the remote Didomi backend. true if the user status was applied from the remote, false otherwise.

syncAcknowledged

Lambda expression

Callback that can be used to communicate to the Didomi servers that the synchronization has been communicated to the user. Returns true if the API event was successfully sent, false otherwise.

Example

languageUpdated

Triggered when SDK language has been successfully changed.

Listener parameters

LanguageUpdatedEvent object with the following property:

Method

Type

Description

languageCode

String

The language code applied

Example

languageUpdateFailed

Triggered when SDK language update has failed.

Listener parameters

LanguageUpdateFailedEvent object with the following property:

Method

Type

Description

reason

String

The reason of the failure

Example

integrationError

Triggered when an integration with an external SDK is not working as expected. The currently supported external SDKs are Firebase, Airbridge, AppsFlyer, and Branch (see related documentation here). This event indicates that Didomi was not able to update the privacy signals for the specified SDK.

Listener parameters

IntegrationErrorEvent object with the following properties:

Method

Type

Description

integrationName

String

Name of the failing SDK integration, such as Firebase SDK, Airbridge SDK...

reason

String

Technical reason of the failure

Example

Last updated