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
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
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
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
onNoticeClickAgree
Triggered when the user clicks on agree on the notice.
Listener parameters
event: EventType (enum)
Example
onNoticeClickMoreInfo
Triggered when the user clicks on learn more on the notice.
Listener parameters
event: EventType (enum)
Example
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
onShowPreferences
Triggered when the preferences screen gets displayed.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickAgreeToAll
Triggered when the user clicks on agree to all on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickDisagreeToAll
Triggered when the user clicks on disagree to all on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickPurposeAgree
Triggered when the user agrees to a purpose on the preferences popup.
Listener parameters
event: EventType (enum)
purposeId: String
Example
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
onPreferencesClickViewVendors
Triggered when the user clicks on view vendors on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickViewSPIPurposes
Triggered when the user clicks on view Sensitive Personal Information from the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickSaveChoices
Triggered when the user saves his choice on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickVendorAgree
Triggered when the user agrees to a vendor on the preferences popup.
Listener parameters
event: EventType (enum)
vendorId: String
Example
onPreferencesClickVendorDisagree
Triggered when the user disagrees to a vendor on the preferences popup.
Listener parameters
event: EventType (enum)
vendorId: String
Example
onPreferencesClickVendorSaveChoices
This happens when the user saves his choice on the vendors view on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onNoticeClickDisagree
Triggered when the user clicks on disagree on the notice.
Listener parameters
event: EventType (enum)
Example
onNoticeClickViewVendors
Triggered when the user clicks on partners on the notice.
Listener parameters
event: EventType (enum)
Example
onNoticeClickViewSPIPurposes
Triggered when the user clicks on Sensitive Personal Information from the notice.
Listener parameters
event: EventType (enum)
Example
onNoticeClickPrivacyPolicy
Triggered when the user clicks on privacy policy on the notice (available on TV only).
Listener parameters
event: EventType (enum)
Example
onPreferencesClickAgreeToAllPurposes
Triggered when the user flips ON all purposes switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickDisagreeToAllPurposes
Triggered when the user flips OFF all purposes switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickAgreeToAllVendors
Triggered when the user flips ON all vendors switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickDisagreeToAllVendors
Triggered when the user flips OFF all vendors switch on the preferences popup.
Listener parameters
event: EventType (enum)
Example
onPreferencesClickViewPurposes
Triggered when the user clicks on view purposes on the preferences popup.
Listener parameters
event: EventType (enum)
Example
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
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
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
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
onPreferencesClickSPIPurposeSaveChoices
Triggered when the Save button from the Sensitive Personal Information screen is pressed.
Listener parameters
event: EventType (enum)
Example
onSyncUserChanged
Triggered when the user is changed from setUser function only if sync is enabled.
Listener parameters
SyncUserChangedEvent: objectPropertyTypeDescriptionuserAuth
UserAuth
The new user as
UserAuthWithoutParams,UserAuthWithEncryptionParamsorUserAuthWithHashParams.
Example
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
onSyncError
Triggered when the consent synchronization has failed (Cross-device).
Listener parameters
event: EventType (enum)
error: String (nullable/optional)
Example
onSyncReady
Triggered when the user status synchronization is ready (Cross-device).
Listener parameters
SyncReadyEvent object
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
onLanguageUpdated
Triggered when SDK language has been successfully changed.
Listener parameters
event: EventType (enum)
languageCode: String (nullable/optional)
Example
onLanguageUpdateFailed
Triggered when SDK language update has failed. (reason provided as a parameter)
Listener parameters
event: EventType (enum)
reason: String (nullable/optional)
Example
onIntegrationError
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