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

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.

Requires SDK to be initialized

No.

Parameters

Name

Type

Description

eventListener

EventListener

The event listener. An instance of a subclass of EventListener

Returns

Nothing

Example

Swift
Objective-C
Swift
let didomiEventListener = EventListener()
didomiEventListener.onConsentChanged = { event in
// The consent status of the user has changed
}
didomiEventListener.onHideNotice = { event in
// The notice is being hidden
}
didomiEventListener.onShowNotice = { event in
// The notice is being shown
}
didomiEventListener.onNoticeClickAgree = { event in
// Click on agree on notice
}
didomiEventListener.onNoticeClickMoreInfo = { event in
// Click on learn more on notice
}
didomiEventListener.onPreferencesClickAgreeToAll = { event in
// Click on agree to all on preferences popup
}
didomiEventListener.onPreferencesClickDisagreeToAll = { event in
// Click on disagree to all on preferences popup
}
didomiEventListener.onPreferencesClickSaveChoices = { event in
// Click on save on the purposes view on preferences popup
}
didomiEventListener.onPreferencesClickViewVendors = { event in
// Click view vendors on purposes view on preferences popup
}
didomiEventListener.onPreferencesClickPurposeAgree = { event, purposeId in
// Click on agree to a purpose on preferences popup
}
didomiEventListener.onPreferencesClickPurposeDisagree = { event, purposeId in
// Click on disagree to a purpose on preferences popup
}
didomiEventListener.onPreferencesClickVendorAgree = { event, vendorId in
// Click on agree to a vendor on preferences popup
}
didomiEventListener.onPreferencesClickVendorDisagree = { event, vendorId in
// Click on disagree to a vendor on preferences popup
}
didomiEventListener.onPreferencesClickVendorSaveChoices = { event in
// Click on save on the vendors view on preferences popup
}
// From this point below you can find tvOS specific events
didomiEventListener.onNoticeClickDisagree = { event in
// Select disagree on the notice
}
didomiEventListener.onNoticeClickViewVendors = { event in
// Select Our Partners on the notice
}
didomiEventListener.onNoticeClickPrivacyPolicy = { event in
// Select Our Privacy Policy on the notice
}
didomiEventListener.onPreferencesClickAgreeToAllPurposes = { event in
// Agree to all purposes using the bulk action button on the preferences screen
}
didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { event in
// Disagree to all purposes using the bulk action button on the preferences screen
}
didomiEventListener.onPreferencesClickAgreeToAllVendors = { event in
// Agree to all vendors using the bulk action button on the preferences screen
}
didomiEventListener.onPreferencesClickDisagreeToAllVendors = { event in
// Disagree to all vendors using the bulk action button on the preferences screen
}
didomiEventListener.onPreferencesClickViewPurposes = { event in
// Select displaying the purposes on the preferences screen
}
Didomi.shared.addEventListener(listener: didomiEventListener)
Objective-C
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnConsentChanged:^(enum DDMEventType event) {
// The consent status of the user has changed
}];
[didomiEventListener setOnHideNotice:^(enum DDMEventType event) {
// The notice is being hidden
}];
[didomiEventListener setOnShowNotice:^(enum DDMEventType event) {
// The notice is being shown
}];
[didomiEventListener setOnNoticeClickAgree:^(enum DDMEventType event) {
// Click on agree on notice
}];
[didomiEventListener setOnNoticeClickMoreInfo:^(enum DDMEventType event) {
// Click on learn more on notice
}];
[didomiEventListener setOnPreferencesClickAgreeToAll:^(enum DDMEventType event) {
// Click on agree to all on preferences popup
}];
[didomiEventListener setOnPreferencesClickDisagreeToAll:^(enum DDMEventType event) {
// Click on disagree to all on preferences popup
}];
[didomiEventListener setOnPreferencesClickSaveChoices:^(enum DDMEventType event) {
// Click on save on the purposes view on preferences popup
}];
[didomiEventListener setOnPreferencesClickViewVendors:^(enum DDMEventType event) {
// Click view vendors on purposes view on preferences popup
}];
[didomiEventListener setOnPreferencesClickPurposeAgree:^(enum DDMEventType event, purposeId) {
// Click on agree to a purpose on preferences popup
}];
[didomiEventListener setOnPreferencesClickPurposeDisagree:^(enum DDMEventType event, purposeId) {
// Click on disagree to a purpose on preferences popup
}];
[didomiEventListener setOnPreferencesClickVendorAgree:^(enum DDMEventType event, vendorId) {
// Click on agree to a vendor on preferences popup
}
[didomiEventListener setOnPreferencesClickVendorDisagree:^(enum DDMEventType event, vendorId) {
// Click on disagree to a vendor on preferences popup
}];
[didomiEventListener setOnPreferencesClickVendorSaveChoices:^(enum DDMEventType event) {
// Click on save on the vendors view on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];

Event types

The following events are supported by the Didomi SDK:

Method

Description

onConsentChanged

When a consent is given or withdrawn by the user. Only triggered when the consent status actually changes (ie if the user saves consents without adding/removing any consent then this does not get called).

onHideNotice

When the consent notice is hidden. If you have disabled our default consent notice to replace it with your own, you need to hide your custom notice when this event gets triggered.

onShowNotice

When the consent notice gets displayed. If you have disabled our default consent notices to replace them with your own, you need to show your custom notice when this event gets triggered.

onNoticeClickAgree

When user clicks on agree on the notice

onNoticeClickMoreInfo

When user clicks on learn more on the notice

onPreferencesClickAgreeToAll

When user clicks on agree to all on the preferences popup

onPreferencesClickDisagreeToAll

When user clicks on disagree to all on the preferences popup

onPreferencesClickPurposeAgree

When user agree to a purpose on the preferences popup. (purposeId provided as a parameter)

onPreferencesClickPurposeDisagree

When user disagree to a purpose on the preferences popup. (purposeId provided as a parameter)

onPreferencesClickViewVendors

When user clicks on view vendors on the preferences popup

onPreferencesClickSaveChoices

When user saves his choice on the preferences popup

onPreferencesClickVendorAgree

When user agree to a vendor on the preferences popup. (vendorId provided as a parameter)

onPreferencesClickVendorDisagree

When user disagree to a vendor on the preferences popup. (vendorId provided as a parameter)

onPreferencesClickVendorSaveChoices

When user saves his choice on the vendors view on the preferences popup

onNoticeClickDisagree

When user clicks on disagree on the notice

onNoticeClickViewVendors*

When user clicks on partners on the notice

onNoticeClickPrivacyPolicy*

When user clicks on privacy policy on the notice

onPreferencesClickAgreeToAllPurposes*

When user flips ON all purposes switch on the preferences popup

onPreferencesClickDisagreeToAllPurposes*

When user flips OFF all purposes switch on the preferences popup

onPreferencesClickAgreeToAllVendors*

When user flips ON all vendors switch on the preferences popup

onPreferencesClickDisagreeToAllVendors*

When user flips OFF all vendors switch on the preferences popup

onPreferencesClickViewPurposes*

When user clicks on view purposes on the preferences popup

* Events marked with asterisk are relevant only for tvOS for now