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

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.onHidePreferences = { event in
    // The preferences screen is being hidden
}

didomiEventListener.onShowPreferences = { event in
    // The preferences screen is being shown
}

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
}

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 (tvOS only)
}

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)

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

onHidePreferences

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

onShowPreferences

When the preferences screen gets displayed.

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

onPreferencesClickViewSPIPurposes

When user clicks on view Sensitive Personal Information from 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

onNoticeClickViewSPIPurposes

When user clicks on Sensitive Personal Information from the notice

onNoticeClickPrivacyPolicy

When user clicks on privacy policy on the notice (available on TV only)

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

onPreferencesClickSPIPurposeAgree

When the toggle linked to an Personal Data purpose is set to agree/enabled

onPreferencesClickSPIPurposeDisagree

When the toggle linked to an Personal Data purpose is set to disagree/disabled

onPreferencesClickSPICategoryAgree

When the toggle linked to an Personal Data category is set to agree/enabled

onPreferencesClickSPICategoryDisagree

When the toggle linked to an Personal Data category is set to disagree/disabled

onPreferencesClickSPIPurposeSaveChoices

When the Save button from the Sensitive Personal Information screen is pressed

onSyncDone

When the consent synchronization is successful (Cross-device)

onSyncError

When the consent synchronization has failed (Cross-device)

onLanguageUpdated

When SDK language has been successfully changed. (languageCode provided as a parameter)

onLanguageUpdateFailed

When SDK language update has failed. (reason provided as a parameter)

Last updated