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
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}Didomi.shared.addEventListener(listener: didomiEventListener)
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
}];
[didomi addEventListenerWithListener:didomiEventListener];
Event types
This section presents a comprehensive list of the event types exposed by the Didomi SDK and usage examples.
onConsentChanged
Triggered when a consent is given or withdrawn by the user. It's only triggered when the consent status actually changes. For instance, if the user saves consents without adding/removing any consent then this does not get called.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onConsentChanged = { event in// The consent status of the user has changed}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnConsentChanged:^(enum DDMEventType event) {
// The consent status of the user has changed
}];
[didomi addEventListenerWithListener:didomiEventListener];
onHideNotice
Triggered 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.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onHideNotice = { event in// The notice is being hidden}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnHideNotice:^(enum DDMEventType event) {
// The notice is being hidden
}];
[didomi addEventListenerWithListener:didomiEventListener];
onShowNotice
Triggered 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.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onShowNotice = { event in// The notice is being shown}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnShowNotice:^(enum DDMEventType event) {
// The notice is being shown
}];
[didomi addEventListenerWithListener:didomiEventListener];
onNoticeClickAgree
Triggered when the user clicks on agree on the notice.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickAgree = { event in// Click on agree on notice}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnNoticeClickAgree:^(enum DDMEventType event) {
// Click on agree on notice
}];
[didomi addEventListenerWithListener:didomiEventListener];
onNoticeClickMoreInfo
Triggered when the user clicks on learn more on the notice.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickMoreInfo = { event in// Click on learn more on notice}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnNoticeClickMoreInfo:^(enum DDMEventType event) {
// Click on learn more on notice
}];
[didomi addEventListenerWithListener:didomiEventListener];
onHidePreferences
Triggered when the preferences screen becomes hidden, for example when the user closes it or saves their consent.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onHidePreferences = { event in// The preferences screen is being hidden}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnHidePreferences:^(enum DDMEventType event) {
// The preferences screen is being hidden
}];
[didomi addEventListenerWithListener:didomiEventListener];
onShowPreferences
Triggered when the preferences screen gets displayed.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onShowPreferences = { event in// The preferences screen is being shown}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnShowPreferences:^(enum DDMEventType event) {
// The preferences screen is being shown
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickAgreeToAll
Triggered when the user clicks on agree to all on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickAgreeToAll = { event in// Click on agree to all on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickAgreeToAll:^(enum DDMEventType event) {
// Click on agree to all on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickDisagreeToAll
Triggered when the user clicks on disagree to all on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickDisagreeToAll = { event in// Click on disagree to all on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickDisagreeToAll:^(enum DDMEventType event) {
// Click on disagree to all on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickPurposeAgree
Triggered when the user agrees to a purpose on the preferences popup.
Listener parameters
event: EventType (enum)
purposeId: String
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickPurposeAgree = { event, purposeId in// Click on agree to a purpose on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickPurposeAgree:^(enum DDMEventType event, purposeId) {
// Click on agree to a purpose on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickPurposeDisagree
Triggered when the user disagrees to a purpose on the preferences popup. (purposeId provided as a parameter)
Listener parameters
event: EventType (enum)
purposeId: String
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickPurposeDisagree = { event, purposeId in// Click on disagree to a purpose on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickPurposeDisagree:^(enum DDMEventType event, purposeId) {
// Click on disagree to a purpose on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickViewVendors
Triggered when the user clicks on view vendors on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickViewVendors = { event in// Click view vendors on purposes view on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
Triggered when the user clicks on view Sensitive Personal Information from the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickViewSPIPurposes = { event in// User clicked on view Sensitive Personal Information from the preferences popup.}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickViewSPIPurposes:^(enum DDMEventType event) {
// User clicked on view Sensitive Personal Information from the preferences popup.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSaveChoices
Triggered when the user saves his choice on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickSaveChoices = { event in// Click on save on the purposes view on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSaveChoices:^(enum DDMEventType event) {
// Click on save on the purposes view on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickVendorAgree
Triggered when the user agrees to a vendor on the preferences popup.
Listener parameters
event: EventType (enum)
vendorId: String
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickVendorAgree = { event, vendorId in// Click on agree to a vendor on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickVendorAgree:^(enum DDMEventType event, vendorId) {
// Click on agree to a vendor on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickVendorDisagree
Triggered when the user disagrees to a vendor on the preferences popup.
Listener parameters
event: EventType (enum)
vendorId: String
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickVendorDisagree = { event, vendorId in// Click on disagree to a vendor on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickVendorDisagree:^(enum DDMEventType event, vendorId) {
// Click on disagree to a vendor on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickVendorSaveChoices
This happens when the user saves his choice on the vendors view on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickVendorSaveChoices = { event in// Click on save on the vendors view on preferences popup}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickVendorSaveChoices:^(enum DDMEventType event) {
// Click on save on the vendors view on preferences popup
}];
[didomi addEventListenerWithListener:didomiEventListener];
onNoticeClickDisagree
Triggered when the user clicks on disagree on the notice.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickDisagree = { event in// Select disagree on the notice}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnNoticeClickDisagree:^(enum DDMEventType event) {
// Select disagree on the notice
}];
[didomi addEventListenerWithListener:didomiEventListener];
onNoticeClickViewVendors
Triggered when the user clicks on partners on the notice.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickViewVendors = { event in// Select Our Partners on the notice}Didomi.shared.addEventListener(listener: didomiEventListener)
Triggered when the user clicks on Sensitive Personal Information from the notice.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickViewSPIPurposes = { event in// User clicked on Sensitive Personal Information from the notice.}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnNoticeClickViewSPIPurposes:^(enum DDMEventType event) {
// User clicked on Sensitive Personal Information from the notice.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onNoticeClickPrivacyPolicy
Triggered when the user clicks on privacy policy on the notice (available on TV only).
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onNoticeClickPrivacyPolicy = { event in// Select Our Privacy Policy on the notice (tvOS only)}Didomi.shared.addEventListener(listener: didomiEventListener)
Triggered when the user flips ON all purposes switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickAgreeToAllPurposes = { event in// Agree to all purposes using the bulk action button on the preferences screen}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickAgreeToAllPurposes:^(enum DDMEventType event) {
// Agree to all purposes using the bulk action button on the preferences screen
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickDisagreeToAllPurposes
Triggered when the user flips OFF all purposes switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { event in// Disagree to all purposes using the bulk action button on the preferences screen}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickDisagreeToAllPurposes:^(enum DDMEventType event) {
// Disagree to all purposes using the bulk action button on the preferences screen
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickAgreeToAllVendors
Triggered when the user flips ON all vendors switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener =EventListener()didomiEventListener.onPreferencesClickAgreeToAllVendors = { event in// Agree to all vendors using the bulk action button on the preferences screen}Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickAgreeToAllVendors:^(enum DDMEventType event) {
// Agree to all vendors using the bulk action button on the preferences screen
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickDisagreeToAllVendors
Triggered when the user flips OFF all vendors switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickDisagreeToAllVendors = { event in
// Disagree to all vendors using the bulk action button on the preferences screen
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickDisagreeToAllVendors:^(enum DDMEventType event) {
// Disagree to all vendors using the bulk action button on the preferences screen
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickViewPurposes
Triggered when the user clicks on view purposes on the preferences popup.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickViewPurposes = { event in
// Select displaying the purposes on the preferences screen
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickViewPurposes:^(enum DDMEventType event) {
// Select displaying the purposes on the preferences screen
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSPIPurposeAgree
Triggered when the toggle linked to a Personal Data purpose is set to agree/enabled.
Listener parameters
event: EventType (enum)
purposeId: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickSPIPurposeAgree = { event, purposeId in
// Toggle linked to a Personal Data purpose was set to agree/enabled.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSPIPurposeAgree:^(enum DDMEventType event, NSString * _Nullable purposeId) {
// Toggle linked to a Personal Data purpose was set to agree/enabled.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSPIPurposeDisagree
Triggered when the toggle linked to a Personal Data purpose is set to disagree/disabled.
Listener parameters
event: EventType (enum)
purposeId: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickSPIPurposeDisagree = { event, purposeId in
// Toggle linked to a Personal Data purpose was set to disagree/disabled.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSPIPurposeDisagree:^(enum DDMEventType event, NSString * _Nullable purposeId) {
// Toggle linked to a Personal Data purpose was set to disagree/disabled.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSPICategoryAgree
Triggered when the toggle linked to a Personal Data category is set to agree/enabled.
Listener parameters
event: EventType (enum)
categoryId: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickSPICategoryAgree = { event, categoryId in
// Toggle linked to a Personal Data category was set to agree/enabled.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSPICategoryAgree:^(enum DDMEventType event, NSString * _Nullable categoryId) {
// Toggle linked to a Personal Data category was set to agree/enabled.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSPICategoryDisagree
Triggered when the toggle linked to a Personal Data category is set to disagree/disabled.
Listener parameters
event: EventType (enum)
categoryId: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickSPICategoryDisagree = { event, categoryId in
// Toggle linked to a Personal Data category was set to disagree/disabled.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSPICategoryDisagree:^(enum DDMEventType event, NSString * _Nullable categoryId) {
// Toggle linked to a Personal Data category was set to disagree/disabled.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onPreferencesClickSPIPurposeSaveChoices
Triggered when the Save button from the Sensitive Personal Information screen is pressed.
Listener parameters
event: EventType (enum)
Example
let didomiEventListener = EventListener()
didomiEventListener.onPreferencesClickSPIPurposeSaveChoices = { event in
// Save button from the Sensitive Personal Information screen was pressed.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnPreferencesClickSPIPurposeSaveChoices:^(enum DDMEventType event) {
// Save button from the Sensitive Personal Information screen was pressed.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onSyncDone
This event has been deprecated. Use onSyncReady instead.
Triggered when the consent synchronization is successful (Cross-device).
Listener parameters
event: EventType (enum)
organizationUserId: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onSyncDone = { event, organizationUserId in
// The consent synchronization was successful.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
Triggered when the consent synchronization has failed (Cross-device).
Listener parameters
event: EventType (enum)
error: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onSyncError = { event, error in
// The consent synchronization has failed.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
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
let didomiEventListener = EventListener()
didomiEventListener.onSyncReady = { event in
// User status synchronization was successful.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnSyncReady:^(enum DDMEventReady event) {
// The consent synchronization was successful.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onLanguageUpdated
Triggered when SDK language has been successfully changed.
Listener parameters
event: EventType (enum)
languageCode: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onLanguageUpdated = { event, languageCode in
// SDK language has been successfully changed.
}
Didomi.shared.addEventListener(listener: didomiEventListener)
DDMEventListener *didomiEventListener = [[DDMEventListener alloc] init];
[didomiEventListener setOnLanguageUpdated:^(enum DDMEventType event, NSString * _Nullable languageCode) {
// SDK language has been successfully changed.
}];
[didomi addEventListenerWithListener:didomiEventListener];
onLanguageUpdateFailed
Triggered when SDK language update has failed. (reason provided as a parameter)
Listener parameters
event: EventType (enum)
reason: String (nullable/optional)
Example
let didomiEventListener = EventListener()
didomiEventListener.onLanguageUpdateFailed = { event, reason in
// SDK language update has failed.
}
Didomi.shared.addEventListener(listener: didomiEventListener)