# Events

The Didomi SDK triggers various events to notify you that the user has taken some action (changed their consent status, opened 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**

{% tabs %}
{% tab title="Java" %}

```java
import io.didomi.sdk.events.EventListener;
import io.didomi.sdk.events.ConsentChangedEvent;

Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // React to consent changed
    }
    
    @Override
    public void showNotice(ShowNoticeEvent event) {
        // React to notice being shown
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import io.didomi.sdk.events.EventListener
import io.didomi.sdk.events.ConsentChangedEvent

Didomi.getInstance().addEventListener(object : EventListener() {
    override fun consentChanged(event: ConsentChangedEvent) {
        // React to consent changed
    }

    override fun showNotice(event: ShowNoticeEvent) {
        // React to notice being shown
    }
})
```

{% endtab %}
{% endtabs %}

## 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void consentChanged(ConsentChangedEvent event) {
        // The consent status of the user has changed
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun consentChanged(event: ConsentChangedEvent) {
        // The consent status of the user has changed
    }
})
```

{% endtab %}
{% endtabs %}

### error

Triggered when an unexpected situation occurs, for example an error during the initialization process.

#### **Listener parameters**

`ErrorEvent` object with the following properties:

| Name           | Type               | Description                                                                                                                                                                                                                                             |
| -------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `errorMessage` | `String`           | String describing the reason of the error.                                                                                                                                                                                                              |
| `errorType`    | `ErrorType` (enum) | <p>One of the following values:</p><p><code>NULL\_PROPERTY</code>, <code>CONFIG\_FILE\_ERROR</code>, <code>INVALID\_API\_KEY</code>, <code>INITIALIZATION\_ERROR</code>, <code>WEB\_SDK\_ERROR</code> or <code>ERROR\_LOADING\_UI\_RESOURCE</code>.</p> |

#### **Example**

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void error(ErrorEvent event) {
        // An error occurred with message `event.errorMessage`
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
  override fun error(event: ErrorEvent) {
    // An error occurred with message `event.errorMessage`
  }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void hideNotice(HideNoticeEvent event) {
        // The notice is being hidden
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun hideNotice(event: HideNoticeEvent) {
        // The notice is being hidden
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void showNotice(ShowNoticeEvent event) {
        // The notice is being shown
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun showNotice(event: ShowNoticeEvent) {
        // The notice is being shown
    }
})
```

{% endtab %}
{% endtabs %}

### noticeClickAgree

Triggered when the user clicks on the `Agree and close` button of a consent notice.

**Listener parameters**

`NoticeClickAgreeEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickAgree(NoticeClickAgreeEvent event) {
        // Click on agree on notice
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickAgree(event: NoticeClickAgreeEvent) {
        // Click on agree on notice
    }
})
```

{% endtab %}
{% endtabs %}

### noticeClickDisagree

Triggered when the user clicks on the `Decline` button of a consent notice.

**Listener parameters**

`NoticeClickDisagreeEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickDisagree(NoticeClickDisagreeEvent event) {
        // Click on disagree on the notice
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickDisagree(event: NoticeClickDisagreeEvent) {
        // Click on disagree on the notice
    }
})
```

{% endtab %}
{% endtabs %}

### noticeClickMoreInfo

Triggered when the user clicks on the `Learn More` button of a consent notice.

**Listener parameters**

`NoticeClickMoreInfoEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickMoreInfo(NoticeClickMoreInfoEvent event) {
        // Click on learn more on notice
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickMoreInfo(event: NoticeClickMoreInfoEvent) {
        // Click on learn more on notice
    }
})
```

{% endtab %}
{% endtabs %}

### noticeClickViewVendors

Triggered when the user clicks on the partners link/button of a consent notice.

**Listener parameters**

`NoticeClickViewVendorsEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickViewVendors(NoticeClickViewVendorsEvent event) { 
        // Click on partners link/button from the notice
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickViewVendors(event: NoticeClickViewVendorsEvent) { 
        // Click on partners link/button from the notice
    }
})
```

{% endtab %}
{% endtabs %}

### noticeClickViewSPIPurposes

Triggered when the user clicks on the Sensitive Personal Information button of a consent notice.

**Listener parameters**

`NoticeClickViewSPIPurposesEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickViewSPIPurposes(NoticeClickViewSPIPurposesEvent event) { 
        // Click on Sensitive personal information button from the notice
    }
});
```

{% endtab %}

{% tab title="Koltin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickViewSPIPurposes(event: NoticeClickViewSPIPurposesEvent) { 
        // Click on Sensitive personal information button from the notice
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void noticeClickPrivacyPolicy(NoticeClickPrivacyPolicyEvent event) { 
        // Click on privacy policy on the TV notice
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun noticeClickPrivacyPolicy(event: NoticeClickPrivacyPolicyEvent) {
        // Click on privacy policy on the TV notice
    }
})
```

{% endtab %}
{% endtabs %}

### hidePreferences

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

**Listener parameters**

`HidePreferencesEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void hidePreferences(HidePreferencesEvent event) {
        // The preferences screen is being hidden
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun hidePreferences(event: HidePreferencesEvent) {
        // The preferences screen is being hidden
    }
})
```

{% endtab %}
{% endtabs %}

### showPreferences

Triggered when the preferences screen gets displayed.

**Listener parameters**

`ShowPreferencesEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void showPreferences(ShowPreferencesEvent event) {
        // The preferences screen is being shown
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun showPreferences(event: ShowPreferencesEvent) {
        // The preferences screen is being shown
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickAgreeToAll

Triggered when the user clicks on the `Agree to all` button of the preferences screen.

**Listener parameters**

`PreferencesClickAgreeToAllEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAll(PreferencesClickAgreeToAllEvent event) {
        // Click on agree to all on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickAgreeToAll(event: PreferencesClickAgreeToAllEvent) {
        // Click on agree to all on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickDisagreeToAll

Triggered when the user clicks on the `Disagree to all` button of the preferences screen.

**Listener parameters**

`PreferencesClickDisagreeToAllEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAll(PreferencesClickDisagreeToAllEvent event) {
        // Click on disagree to all on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickDisagreeToAll(event: PreferencesClickDisagreeToAllEvent) {
        // Click on disagree to all on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickSaveChoices

Triggered when the user clicks on the `Save` button of the preferences screen.

**Listener parameters**

`PreferencesClickSaveChoicesEvent` object (contains no properties)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSaveChoices(PreferencesClickSaveChoicesEvent event) {
        // Click on save on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSaveChoices(event: PreferencesClickSaveChoicesEvent) {
        // Click on save on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickPurposeAgree

Triggered when the user agrees to an individual purpose on the preferences screen.

**Listener parameters**

`PreferencesClickPurposeAgreeEvent` object with the following property:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>purposeId</code></td><td>String</td><td>Unique ID of the purpose that was enabled</td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickPurposeAgree(PreferencesClickPurposeAgreeEvent event) {
        String purposeId = event.getPurposeId();
        // Agree to a purpose on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickPurposeAgree(event: PreferencesClickPurposeAgreeEvent) {
        val purposeId = event.purposeId
        // Agree to a purpose on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickPurposeDisagree(PreferencesClickPurposeDisagreeEvent event) {
        String purposeId = event.getPurposeId();
        // Disagree to a purpose on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickPurposeDisagree(event: PreferencesClickPurposeDisagreeEvent) {
        val purposeId = event.purposeId
        // Disagree to a purpose on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickCategoryAgree(PreferencesClickCategoryAgreeEvent event) {
        String categoryId = event.getCategoryId();
        // Agree to a category on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickCategoryAgree(event: PreferencesClickCategoryAgreeEvent) {
        val categoryId = event.categoryId
        // Agree to a category on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickCategoryDisagree(PreferencesClickCategoryDisagreeEvent event) {
        String categoryId = event.getCategoryId();
        // Disagree to a category on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickCategoryDisagree(event: PreferencesClickCategoryDisagreeEvent) {
        val categoryId = event.categoryId
        // Disagree to a category on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickViewVendors

Triggered when the user clicks on `View Vendors` buttons on the preferences screen.

**Listener parameters**

`PreferencesClickViewVendorsEvent` object (contains no properties)

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewVendors(PreferencesClickViewVendorsEvent event) {
        // Click view vendors on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickViewVendors(event: PreferencesClickViewVendorsEvent) {
        // Click view vendors on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickViewSPIPurposes

Triggered when the user clicks on `Sensitive Personal Information` button from preferences screen.

**Listener parameters**

`PreferencesClickViewSPIPurposesEvent` object (contains no property)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewSPIPurposes(PreferencesClickViewSPIPurposesEvent event) { 
        // Click on view Sensitive Personal Information from the preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickViewSPIPurposes(event: PreferencesClickViewSPIPurposesEvent) { 
        // Click on view Sensitive Personal Information from the preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorAgree(PreferencesClickVendorAgreeEvent event) {
        String vendorId = event.getVendorId();
        // Agree to a vendor on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickVendorAgree(event: PreferencesClickVendorAgreeEvent) {
        val vendorId = event.vendorId
        // Agree to a vendor on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorDisagree(PreferencesClickVendorAgreeEvent event) {
        String vendorId = event.getVendorId();
        // Disagree to a vendor on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickVendorDisagree(event: PreferencesClickVendorAgreeEvent) {
        val vendorId = event.vendorId
        // Disagree to a vendor on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAllVendors(PreferencesClickAgreeToAllVendorsEvent event) {
        // Flip ON all vendors switch on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickAgreeToAllVendors(event: PreferencesClickAgreeToAllVendorsEvent) {
        // Flip ON all vendors switch on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAllVendors(PreferencesClickDisagreeToAllVendorsEvent event) {
        // Flip OFF all vendors switch on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAllVendors(PreferencesClickDisagreeToAllVendorsEvent event) {
        // Flip OFF all vendors switch on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### preferencesClickVendorSaveChoices

Triggered when the user clicks on `Save` button on the vendors view on preferences screen.

**Listener parameters**

`PreferencesClickVendorSaveChoicesEvent` object (contains no property)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickVendorSaveChoices(PreferencesClickVendorSaveChoicesEvent event) {
        // Click on save on the vendors view on preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickVendorSaveChoices(event: PreferencesClickVendorSaveChoicesEvent) {
        // Click on save on the vendors view on preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickViewPurposes(PreferencesClickViewPurposesEvent event) { 
        // Click on view purposes on the TV preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickViewPurposes(event: PreferencesClickViewPurposesEvent) { 
        // Click on view purposes on the TV preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickAgreeToAllPurposes(PreferencesClickAgreeToAllPurposesEvent event) { 
        // Flip ON all purposes switch on the preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickAgreeToAllPurposes(event: PreferencesClickAgreeToAllPurposesEvent) {
        // Flip ON all purposes switch on the preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickDisagreeToAllPurposes(PreferencesClickAgreeToAllPurposesEvent event) { 
        // Flip OFF all purposes switch on the preferences popup
    }
});
```

{% endtab %}
{% endtabs %}

### preferencesClickSPIPurposeAgree

Triggered when the user agrees to an individual Personal Data purpose from the preferences screen.

**Listener parameters**

`PreferencesClickSPIPurposeAgreeEvent` object with the following property:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>purposeId</code></td><td>String</td><td>Unique ID of the purpose that was enabled</td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeAgree(PreferencesClickSPIPurposeAgreeEvent event) {
        String purposeId = event.getPurposeId();
        // Agree to a Personal Data purpose from preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSPIPurposeAgree(event: PreferencesClickSPIPurposeAgreeEvent) {
        val purposeId = event.purposeId
        // Agree to a Personal Data purpose from preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeDisagree(PreferencesClickSPIPurposeDisagreeEvent event) {
        String purposeId = event.getPurposeId();
        // Disagree to a Personal Data purpose from preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSPIPurposeDisagree(event: PreferencesClickSPIPurposeDisagreeEvent) {
        val purposeId = event.purposeId
        // Disagree to a Personal Data purpose from preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPICategoryAgree(PreferencesClickSPICategoryAgreeEvent event) {
        String categoryId = event.getCategoryId();
        // Agree to a Personal Data category from preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSPICategoryAgree(event: PreferencesClickSPICategoryAgreeEvent) {
        val categoryId = event.categoryId
        // Agree to a Personal Data category from preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPICategoryDisagree(PreferencesClickSPICategoryDisagreeEvent event) {
        String categoryId = event.getCategoryId();
        // Disagree to a Personal Data category from preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSPICategoryDisagree(event: PreferencesClickSPICategoryDisagreeEvent) {
        val categoryId = event.categoryId
        // Disagree to a Personal Data category from preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void preferencesClickSPIPurposeSaveChoices(PreferencesClickSPIPurposeSaveChoicesEvent event) {
        // Click on save on the Sensitive Personal Information view from preferences popup
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun preferencesClickSPIPurposeSaveChoices(event: PreferencesClickSPIPurposeSaveChoicesEvent) {
        // Click on save on the Sensitive Personal Information view from preferences popup
    }
})
```

{% endtab %}
{% endtabs %}

### syncUserChanged

Triggered when the user is changed from [setUser](/cmp/mobile-sdk/react-native/reference.md#setuser) function only if sync is enabled.

**Listener parameters**

`SyncUserChangedEvent` object with the following property:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>userAuth</code></td><td>UserAuth</td><td>The new user as <code>UserAuthWithoutParams</code>, <code>UserAuthWithEncryptionParams</code> or <code>UserAuthWithHashParams</code></td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncUserChanged(SyncUserChangedEvent event) { 
        UserAuth userAuth = event.userAuth
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun syncUserChanged(event: SyncUserChangedEvent) {
        val userAuth = event.userAuth
    }
})
```

{% endtab %}
{% endtabs %}

### syncDone

{% hint style="warning" %}
This event has been deprecated. Use [syncReady](#syncready) instead.
{% endhint %}

Triggered when the consent synchronization is successful (Cross-device).

**Listener parameters**

`SyncDoneEvent` object (contains no property)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncDone(SyncDoneEvent event) { 
        // Synchronization success
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun syncDone(event: SyncDoneEvent) {
        // Synchronization success
    }
})
```

{% endtab %}
{% endtabs %}

### syncError

Triggered when the consent synchronization has failed (Cross-device).

**Listener parameters**

`SyncErrorEvent` object (contains no property)

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncError(SyncErrorEvent event) { 
        // Synchronization failure
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun syncError(event: SyncErrorEvent) {
        // Synchronization failure
    }
})
```

{% endtab %}
{% endtabs %}

### **syncReady**

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**

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void syncReady(SyncReadyEvent event) { 
        // User status synchronization was successful.
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun syncReady(event: SyncReadyEvent) {
        // User status synchronization was successful.
    }
})
```

{% endtab %}
{% endtabs %}

### languageUpdated

Triggered when SDK language has been successfully changed.

**Listener parameters**

`LanguageUpdatedEvent` object with the following property:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>languageCode</code></td><td>String</td><td>The language code applied</td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void languageUpdated(LanguageUpdatedEvent event) { 
        // Language has been changed
        String languageCode = event.languageCode;
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun languageUpdated(event: LanguageUpdatedEvent) {
        // Language has been changed
        val languageCode = event.languageCode
    }
})
```

{% endtab %}
{% endtabs %}

### languageUpdateFailed

Triggered when SDK language update has failed.

**Listener parameters**

`LanguageUpdateFailedEvent` object with the following property:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>reason</code></td><td>String</td><td>The reason of the failure</td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void languageUpdateFailed(LanguageUpdateFailedEvent event) { 
        // Language update failure
        String reason = event.reason;
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun languageUpdateFailed(event: LanguageUpdateFailedEvent) {
        // Language update failure
        val reason = event.reason
    }
})
```

{% endtab %}
{% endtabs %}

### integrationError

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](/cmp/mobile-sdk/google-consent-mode.md#how-does-it-work-on-apps)). 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:

<table data-header-hidden><thead><tr><th>Method</th><th width="171.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>Method</td><td>Type</td><td>Description</td></tr><tr><td><code>integrationName</code></td><td>String</td><td>Name of the failing SDK integration, such as <code>Firebase SDK</code>, <code>Airbridge SDK</code>...</td></tr><tr><td><code>reason</code></td><td>String</td><td>Technical reason of the failure</td></tr></tbody></table>

#### Example

{% tabs %}
{% tab title="Java" %}

```java
Didomi.getInstance().addEventListener(new EventListener() {
    @Override
    public void integrationError(IntegrationErrorEvent event) { 
        // An external SDK integration is not working properly
        Log.w(event.integrationName + " : Integration error - " + event.reason);
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
Didomi.getInstance().addEventListener(object : EventListener() {
    override fun integrationError(event: IntegrationErrorEvent) {
        // An external SDK integration is not working properly
        Log.w("${event.integrationName} : Integration error - ${event.reason}")
    }
})
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/cmp/mobile-sdk/android/reference/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
