Events

The Didomi SDK triggers various events to notify you that the user has taken some action (changed their consent status, open 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

NameTypeDescription

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // The consent status of the user has changed
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void hideNotice(HideNoticeEvent event) {
        // The notice is being hidden
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void showNotice(ShowNoticeEvent event) {
        // The notice is being shown
    }
});

noticeClickAgree

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

Listener parameters

NoticeClickAgreeEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickAgree(NoticeClickAgreeEvent event) {
        // Click on agree on notice
    }
});

noticeClickDisagree

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

Listener parameters

NoticeClickDisagreeEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickDisagree(NoticeClickDisagreeEvent event) {
        // Click on disagree on the notice
    }
});

noticeClickMoreInfo

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

Listener parameters

NoticeClickMoreInfoEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickMoreInfo(NoticeClickMoreInfoEvent event) {
        // Click on learn more on notice
    }
});

noticeClickViewVendors

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

Listener parameters

NoticeClickViewVendorsEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickViewVendors(NoticeClickViewVendorsEvent event) { 
        // Click on partners link/button from the notice
    }
});

noticeClickViewSPIPurposes

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

Listener parameters

NoticeClickViewSPIPurposesEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickViewSPIPurposes(NoticeClickViewSPIPurposesEvent event) { 
        // Click on Sensitive personal information button from the notice
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickPrivacyPolicy(NoticeClickPrivacyPolicyEvent event) { 
        // Click on privacy policy on the TV notice
    }
});

hidePreferences

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

Listener parameters

HidePreferencesEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void hidePreferences(HidePreferencesEvent event) {
        // The preferences screen is being hidden
    }
});

showPreferences

Triggered when the preferences screen gets displayed.

Listener parameters

ShowPreferencesEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void showPreferences(ShowPreferencesEvent event) {
        // The preferences screen is being shown
    }
});

preferencesClickAgreeToAll

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

Listener parameters

PreferencesClickAgreeToAllEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAll(PreferencesClickAgreeToAllEvent event) {
        // Click on agree to all on preferences popup
    }
});

preferencesClickDisagreeToAll

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

Listener parameters

PreferencesClickDisagreeToAllEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAll(PreferencesClickDisagreeToAllEvent event) {
        // Click on disagree to all on preferences popup
    }
});

preferencesClickSaveChoices

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

Listener parameters

PreferencesClickSaveChoicesEvent object (contains no properties)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSaveChoices(PreferencesClickSaveChoicesEvent event) {
        // Click on save on preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickPurposeAgree(PreferencesClickPurposeAgreeEvent event) {
        String purposeId = event.getPurposeId();
        // Agree to a purpose on preferences popup
    }
});

preferencesClickPurposeDisagree

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

Listener parameters

PreferencesClickPurposeDisagreeEvent object with the following property:

MethodTypeDescription

purposeId

String

Unique ID of the purpose that was disabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickPurposeDisagree(PreferencesClickPurposeDisagreeEvent event) {
        String purposeId = event.getPurposeId();
        // Disagree to a purpose on preferences popup
    }
});

preferencesClickCategoryAgree

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

Listener parameters

PreferencesClickCategoryAgreeEvent object with the following property:

MethodTypeDescription

categoryId

String

Unique ID of the category that was enabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickCategoryAgree(PreferencesClickCategoryAgreeEvent event) {
        String categoryId = event.getCategoryId();
        // Agree to a category on preferences popup
    }
});

preferencesClickCategoryDisagree

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

Listener parameters

PreferencesClickCategoryDisagreeEvent object with the following property:

MethodTypeDescription

categoryId

String

Unique ID of the category that was disabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickCategoryDisagree(PreferencesClickCategoryDisagreeEvent event) {
        String categoryId = event.getCategoryId();
        // Disagree to a category on preferences popup
    }
});

preferencesClickViewVendors

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

Listener parameters

PreferencesClickViewVendorsEvent object (contains no properties)

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewVendors(PreferencesClickViewVendorsEvent event) {
        // Click view vendors on preferences popup
    }
});

preferencesClickViewSPIPurposes

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

Listener parameters

PreferencesClickViewSPIPurposesEvent object (contains no property)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewSPIPurposes(PreferencesClickViewSPIPurposesEvent event) { 
        // Click on view Sensitive Personal Information from the preferences popup
    }
});

preferencesClickVendorAgree

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

Listener parameters

PreferencesClickVendorAgreeEvent object with the following property:

MethodTypeDescription

vendorId

String

Unique ID of the vendor that was enabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorAgree(PreferencesClickVendorAgreeEvent event) {
        String vendorId = event.getVendorId();
        // Agree to a vendor on preferences popup
    }
});

preferencesClickVendorDisagree

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

Listener parameters

PreferencesClickVendorDisagreeEvent object with the following property:

MethodTypeDescription

vendorId

String

Unique ID of the vendor that was disabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorDisagree(PreferencesClickVendorAgreeEvent event) {
        String vendorId = event.getVendorId();
        // Disagree to a vendor on preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAllVendors(PreferencesClickAgreeToAllVendorsEvent event) {
        // Flip ON all vendors switch on preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAllVendors(PreferencesClickDisagreeToAllVendorsEvent event) {
        // Flip OFF all vendors switch on preferences popup
    }
});

preferencesClickVendorSaveChoices

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

Listener parameters

PreferencesClickVendorSaveChoicesEvent object (contains no property)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorSaveChoices(PreferencesClickVendorSaveChoicesEvent event) {
        // Click on save on the vendors view on preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewPurposes(PreferencesClickViewPurposesEvent event) { 
        // Click on view purposes on the TV preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAllPurposes(PreferencesClickAgreeToAllPurposesEvent event) { 
        // Flip ON all purposes switch on the preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAllPurposes(PreferencesClickAgreeToAllPurposesEvent event) { 
        // Flip OFF all purposes switch on the preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeAgree(PreferencesClickSPIPurposeAgreeEvent event) {
        String purposeId = event.getPurposeId();
        // Agree to a Personal Data purpose from preferences popup
    }
});

preferencesClickSPIPurposeDisagree

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

Listener parameters

PreferencesClickSPIPurposeDisagreeEvent object with the following property:

MethodTypeDescription

purposeId

String

Unique ID of the purpose that was disabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeDisagree(PreferencesClickSPIPurposeDisagreeEvent event) {
        String purposeId = event.getPurposeId();
        // Disagree to a Personal Data purpose from preferences popup
    }
});

preferencesClickSPICategoryAgree

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

Listener parameters

PreferencesClickSPICategoryAgreeEvent object with the following property:

MethodTypeDescription

categoryId

String

Unique ID of the category that was enabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPICategoryAgree(PreferencesClickSPICategoryAgreeEvent event) {
        String categoryId = event.getCategoryId();
        // Agree to a Personal Data category from preferences popup
    }
});

preferencesClickSPICategoryDisagree

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

Listener parameters

PreferencesClickSPICategoryDisagreeEvent object with the following property:

MethodTypeDescription

categoryId

String

Unique ID of the category that was disabled

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPICategoryDisagree(PreferencesClickSPICategoryDisagreeEvent event) {
        String categoryId = event.getCategoryId();
        // Disagree to a Personal Data category from preferences popup
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeSaveChoices(PreferencesClickSPIPurposeSaveChoicesEvent event) {
        // Click on save on the Sensitive Personal Information view from preferences popup
    }
});

syncDone

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

Listener parameters

SyncDoneEvent object (contains no property)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncDone(SyncDoneEvent event) { 
        // Synchronization success
    }
});

syncError

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

Listener parameters

SyncErrorEvent object (contains no property)

Example

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncDone(SyncErrorEvent event) { 
        // Synchronization failure
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void languageUpdated(LanguageUpdatedEvent event) { 
        // Language has been changed
        String languageCode = event.languageCode;
    }
});

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

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void languageUpdateFailed(LanguageUpdateFailedEvent event) { 
        // Language update failure
        String reason = event.reason;
    }
});

Last updated