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
Name
Type
Description
eventListener
EventListener
The event listener. An instance of a subclass of io.didomi.sdk.events.EventListener
Returns
Nothing
Example
importio.didomi.sdk.events.EventListener;importio.didomi.sdk.events.ConsentChangedEvent;Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidconsentChanged(ConsentChangedEvent event) {// React to consent changed } @OverridepublicvoidshowNotice(ShowNoticeEvent event) {// React to notice being shown }});
import io.didomi.sdk.events.EventListenerimport io.didomi.sdk.events.ConsentChangedEventDidomi.getInstance().addEventListener(object : EventListener() {overridefunconsentChanged(event: ConsentChangedEvent) {// React to consent changed }overridefunshowNotice(event: ShowNoticeEvent) {// 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(newEventListener() { @OverridepublicvoidconsentChanged(ConsentChangedEvent event) {// The consent status of the user has changed }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunconsentChanged(event: ConsentChangedEvent) {// 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(newEventListener() { @OverridepublicvoidhideNotice(HideNoticeEvent event) {// The notice is being hidden }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunhideNotice(event: HideNoticeEvent) {// 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(newEventListener() { @OverridepublicvoidshowNotice(ShowNoticeEvent event) {// The notice is being shown }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunshowNotice(event: ShowNoticeEvent) {// 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(newEventListener() { @OverridepublicvoidnoticeClickAgree(NoticeClickAgreeEvent event) {// Click on agree on notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickAgree(event: NoticeClickAgreeEvent) {// 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(newEventListener() { @OverridepublicvoidnoticeClickDisagree(NoticeClickDisagreeEvent event) {// Click on disagree on the notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickDisagree(event: NoticeClickDisagreeEvent) {// 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(newEventListener() { @OverridepublicvoidnoticeClickMoreInfo(NoticeClickMoreInfoEvent event) {// Click on learn more on notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickMoreInfo(event: NoticeClickMoreInfoEvent) {// 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(newEventListener() { @OverridepublicvoidnoticeClickViewVendors(NoticeClickViewVendorsEvent event) { // Click on partners link/button from the notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickViewVendors(event: NoticeClickViewVendorsEvent) { // 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(newEventListener() { @OverridepublicvoidnoticeClickViewSPIPurposes(NoticeClickViewSPIPurposesEvent event) { // Click on Sensitive personal information button from the notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickViewSPIPurposes(event: NoticeClickViewSPIPurposesEvent) { // 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(newEventListener() { @OverridepublicvoidnoticeClickPrivacyPolicy(NoticeClickPrivacyPolicyEvent event) { // Click on privacy policy on the TV notice }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunnoticeClickPrivacyPolicy(event: NoticeClickPrivacyPolicyEvent) {// 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(newEventListener() { @OverridepublicvoidhidePreferences(HidePreferencesEvent event) {// The preferences screen is being hidden }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunhidePreferences(event: HidePreferencesEvent) {// 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(newEventListener() { @OverridepublicvoidshowPreferences(ShowPreferencesEvent event) {// The preferences screen is being shown }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunshowPreferences(event: ShowPreferencesEvent) {// 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(newEventListener() { @OverridepublicvoidpreferencesClickAgreeToAll(PreferencesClickAgreeToAllEvent event) {// Click on agree to all on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickAgreeToAll(event: PreferencesClickAgreeToAllEvent) {// 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(newEventListener() { @OverridepublicvoidpreferencesClickDisagreeToAll(PreferencesClickDisagreeToAllEvent event) {// Click on disagree to all on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickDisagreeToAll(event: PreferencesClickDisagreeToAllEvent) {// 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(newEventListener() { @OverridepublicvoidpreferencesClickSaveChoices(PreferencesClickSaveChoicesEvent event) {// Click on save on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickSaveChoices(event: PreferencesClickSaveChoicesEvent) {// 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(newEventListener() { @OverridepublicvoidpreferencesClickPurposeAgree(PreferencesClickPurposeAgreeEvent event) {String purposeId =event.getPurposeId();// Agree to a purpose on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickPurposeAgree(event: PreferencesClickPurposeAgreeEvent) {val purposeId = event.purposeId// 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:
Method
Type
Description
purposeId
String
Unique ID of the purpose that was disabled
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickPurposeDisagree(PreferencesClickPurposeDisagreeEvent event) {String purposeId =event.getPurposeId();// Disagree to a purpose on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickPurposeDisagree(event: PreferencesClickPurposeDisagreeEvent) {val purposeId = event.purposeId// 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:
Method
Type
Description
categoryId
String
Unique ID of the category that was enabled
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickCategoryAgree(PreferencesClickCategoryAgreeEvent event) {String categoryId =event.getCategoryId();// Agree to a category on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickCategoryAgree(event: PreferencesClickCategoryAgreeEvent) {val categoryId = event.categoryId// 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:
Method
Type
Description
categoryId
String
Unique ID of the category that was disabled
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickCategoryDisagree(PreferencesClickCategoryDisagreeEvent event) {String categoryId =event.getCategoryId();// Disagree to a category on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickCategoryDisagree(event: PreferencesClickCategoryDisagreeEvent) {val categoryId = event.categoryId// 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)
Triggered when the user clicks on Sensitive Personal Information button from preferences screen.
Listener parameters
PreferencesClickViewSPIPurposesEvent object (contains no property)
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickViewSPIPurposes(PreferencesClickViewSPIPurposesEvent event) { // Click on view Sensitive Personal Information from the preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickViewSPIPurposes(event: PreferencesClickViewSPIPurposesEvent) { // 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:
Method
Type
Description
vendorId
String
Unique ID of the vendor that was enabled
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickVendorAgree(PreferencesClickVendorAgreeEvent event) {String vendorId =event.getVendorId();// Agree to a vendor on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickVendorAgree(event: PreferencesClickVendorAgreeEvent) {val vendorId = event.vendorId// 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:
Method
Type
Description
vendorId
String
Unique ID of the vendor that was disabled
Example
Didomi.getInstance().addEventListener(newEventListener() { @OverridepublicvoidpreferencesClickVendorDisagree(PreferencesClickVendorAgreeEvent event) {String vendorId =event.getVendorId();// Disagree to a vendor on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickVendorDisagree(event: PreferencesClickVendorAgreeEvent) {val vendorId = event.vendorId// 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(newEventListener() { @OverridepublicvoidpreferencesClickAgreeToAllVendors(PreferencesClickAgreeToAllVendorsEvent event) {// Flip ON all vendors switch on preferences popup }});
Didomi.getInstance().addEventListener(object : EventListener() {overridefunpreferencesClickAgreeToAllVendors(event: PreferencesClickAgreeToAllVendorsEvent) {// 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(newEventListener() { @OverridepublicvoidpreferencesClickDisagreeToAllVendors(PreferencesClickDisagreeToAllVendorsEvent event) {// Flip OFF all vendors switch on preferences popup }});
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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickVendorSaveChoices(event: PreferencesClickVendorSaveChoicesEvent) {
// 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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickViewPurposes(event: PreferencesClickViewPurposesEvent) {
// 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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickAgreeToAllPurposes(event: PreferencesClickAgreeToAllPurposesEvent) {
// 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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickSPIPurposeAgree(event: PreferencesClickSPIPurposeAgreeEvent) {
val purposeId = event.purposeId
// 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:
Method
Type
Description
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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickSPIPurposeDisagree(event: PreferencesClickSPIPurposeDisagreeEvent) {
val purposeId = event.purposeId
// 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:
Method
Type
Description
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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickSPICategoryAgree(event: PreferencesClickSPICategoryAgreeEvent) {
val categoryId = event.categoryId
// 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:
Method
Type
Description
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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickSPICategoryDisagree(event: PreferencesClickSPICategoryDisagreeEvent) {
val categoryId = event.categoryId
// 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
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun preferencesClickSPIPurposeSaveChoices(event: PreferencesClickSPIPurposeSaveChoicesEvent) {
// Click on save on the Sensitive Personal Information view from preferences popup
}
})
syncDone
This event has been deprecated. Use syncReady instead.
Triggered when the consent synchronization is successful (Cross-device).
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
Didomi.getInstance().addEventListener(new EventListener() {
@Override
public void syncReady(SyncReadyEvent event) {
// User status synchronization was successful.
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun syncDone(event: SyncErrorEvent) {
// User status synchronization was successful.
}
})
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;
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun languageUpdated(event: LanguageUpdatedEvent) {
// Language has been changed
val 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;
}
});
Didomi.getInstance().addEventListener(object : EventListener() {
override fun languageUpdateFailed(event: LanguageUpdateFailedEvent) {
// Language update failure
val reason = event.reason
}
})