# User consent

The Wortise SDK includes support for Google Ads **Consent Manager** (**CMP**) to request the consent of every user.

Obtaining the user consent is important to comply with the privacy policies and qualify for higher CPMs.

## Request consent

To request the user consent, it is needed to invoke the method `ConsentManager.requestIfRequired` at an appropriate moment of the app. This will show a dialog, only when it is required (normally during the first app launch), so the user can grant or deny consent.

There is also the `ConsentManager.request` method to always show the dialog, and not only when required (for example, to provide an option in the app settings to allow the user change the consent at anytime).

### Example

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

```kotlin
// Example with WortiseSdk.initialize
WortiseSdk.initialize(this, "your app key") {
    ConsentManager.requestIfRequired(this);
}

// Example with WortiseSdk.wait
WortiseSdk.wait {
    ConsentManager.requestIfRequired(this);
}
```

{% endtab %}

{% tab title="Java" %}

```java
// Example with WortiseSdk.initialize
WortiseSdk.initialize(this, "tu app key", () -> {
    ConsentManager.requestIfRequired(this);
    return Unit.INSTANCE;
});

// Example with WortiseSdk.wait
WortiseSdk.wait(() -> {
    ConsentManager.requestIfRequired(this);
    return Unit.INSTANCE;
});
```

{% endtab %}
{% endtabs %}

### Listener configuration

It is possible to pass a listener, to both `request` and `requestIfRequired`, to know when the consent requested has finished (and if it has been shown). To achieve this, just pass a listener as the last parameter of both methods.

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

```kotlin
ConsentManager.requestOnce(this, (shown) -> {
    // This listener will be invoked when the request finishes 
}
```

{% endtab %}

{% tab title="Java" %}

```java
ConsentManager.requestOnce(this, (shown) -> {
    // This listener will be invoked when the request finishes 
    return Unit.INSTANCE;
});
```

{% 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://docs.wortise.com/en/android-sdk/user-consent.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.
