> For the complete documentation index, see [llms.txt](https://docs.digitalturbine.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalturbine.com/dt-fairbid/fairbid-sdk/sdk-reference/gdpr.md).

# GDPR

The General Data Protection Regulation ([GDPR](https://gdpr.eu/)) requires you to scope your user's consent. A user falls within the GDPR scope for your app when one more of the following applies:

* The user is currently located in the European Union (EU).
* The user registers with the app as an EU resident.
* The app specifically targets EU users.

For more information about how DT applies GDPR, see [GDPR](https://docs.digitalturbine.com/dt-fairbid/privacy/gdpr.md).

{% hint style="warning" %}
If you do not pass the user's consent to the DT FairBid SDK, the SDK only shows contextual ads to that user, which might negatively impact your revenue.
{% endhint %}

## How the SDK Evaluates Consent

The DT FairBid SDK reads the user's GDPR and TCF Purpose 1 consent once, when the app calls `FairBid.start`. The SDK keeps that consent state until the app process ends.

### Set Consent Before Starting the SDK

To set up consent handling, complete the following steps in order:

1. Obtain the user's consent with your CMP.
2. Set the `IABTCF_*` and `IABGPP_*` values in `SharedPreferences` (Android) or `NSUserDefaults` (iOS), and, if you use the DT FairBid GDPR API, pass the user's consent to the SDK.
3. Start the SDK.

### Consent Behavior After the SDK Starts

* The SDK ignores any consent change after it starts, whether the user grants or revokes consent, and does not store the change to apply it later.
* A call to the DT FairBid GDPR API after the SDK starts is a no-op. The SDK logs a warning that the call was ignored and that an app restart is required.
* To use a changed consent, restart the app, set the new consent before the SDK starts, and start the SDK again.
* If the TCF string and the DT FairBid GDPR API flag contradict each other, the most restrictive signal applies.
* If `IABTCF_gdprApplies` is `0` (`false`), the SDK does not block ad requests. Only an explicit opt-out through the DT FairBid GDPR API (`false`) blocks them.

{% hint style="warning" %}
Complete the consent steps before starting the SDK. After the SDK starts, a consent change or a GDPR API call is a no-op, and the SDK does not apply it later. To use a changed consent, the app must restart.
{% endhint %}

## User Consent Given

Before starting the SDK, use the following API to indicate that the user gives consent:

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

```java
UserInfo.setGdprConsent(true, context);
      // true or YES if you have the user’s consent
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}
{% code title="Swift" %}

```swift
FairBid.user().gdprConsent = true
```

{% endcode %}

{% code title="Objective-C" %}

```objective-c
[FairBid user].GDPRConsent = YES;
```

{% endcode %}
{% endtab %}

{% tab title="Unity" %}
{% code title="C#" %}

```csharp
UserInfo.SetGdprConsent(true);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## User Consent NOT Given

Before starting the SDK, use the following API to indicate that the user does not give consent:

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

```java
UserInfo.setGdprConsent(false, context);
      // false or NOT if you do not have the user’s consent
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}
DT does not support this option for iOS.
{% endtab %}

{% tab title="Unity" %}
{% code title="C#" %}

```csharp
UserInfo.SetGdprConsent(false);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## \[Optional] Additional User Consent String

Before starting the SDK, use the following API to pass an optional consent string:

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

```java
String consentString = "BOEFEAyOEFEAyXXXXXXI4AAAB9vABAASA";
UserInfo.setGdprConsentString(consentString, this);
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}
{% code title="Swift" %}

```swift
FairBid.user().gdprConsentString = "BOEFEAyOEFEAyXXXXXXI4AAAB9vABAASA"
```

{% endcode %}

{% code title="Objective-C" %}

```objective-c
[FairBid user].GDPRConsentString = @"BOEFEAyOEFEAyXXXXXXXI4AAAB9vABAASA";
```

{% endcode %}
{% endtab %}

{% tab title="Unity" %}
{% code title="C#" %}

```csharp
var consentString = "BOEFEAyOEFEAyXXXXXXI4AAAB9vABAASA";
UserInfo.SetGdprConsentString(consentString);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## GDPR FAQs

<details>

<summary>What happens if consent changes after the SDK starts?</summary>

Nothing changes. The SDK reads consent once, at `FairBid.start`, and ignores later changes, whether the user grants or revokes consent. This applies to changes made through the DT FairBid GDPR API and to updates of the `IABTCF_*` and `IABGPP_*` values in `SharedPreferences` or `NSUserDefaults`. The SDK does not store the change to apply it later. To use the changed consent, restart the app and set the consent before the SDK starts.

</details>

<details>

<summary>What happens if I call the GDPR API after the SDK starts?</summary>

The call is a no-op, and the SDK does not apply it later. Call the API before the SDK starts. The SDK logs a warning that the call was ignored and that an app restart is required. This applies to `UserInfo.setGdprConsent`, `UserInfo.setGdprConsentString`, and `UserInfo.clearGdprConsent` on Android, and to the equivalent `FairBid.user()` GDPR properties on iOS and Unity.

</details>

<details>

<summary>How do I apply a user's consent change?</summary>

Restart the app. Calling the API or updating the consent values in the running app has no effect. After the restart, and before starting the SDK, obtain the consent with your CMP and optionally pass it to the DT FairBid GDPR API. Then start the SDK. The SDK evaluates the new consent at that start.

</details>

<details>

<summary>What if the GDPR string and the DT FairBid flag conflict?</summary>

The most restrictive signal applies.

* If you opt out through the DT FairBid GDPR API (`false`), the SDK blocks ad requests even if bit 1 of `IABTCF_PurposeConsents` is `1` or `IABTCF_gdprApplies` is `0`. The SDK logs `[FairBid][TCF] BLOCKED (publisher_opt_out)`.
* If `IABTCF_gdprApplies` is `1` (or is malformed) and bit 1 of `IABTCF_PurposeConsents` is not `1`, the SDK blocks ad requests even if you pass `true` to the DT FairBid GDPR API. The SDK logs `[FairBid][TCF] BLOCKED (purpose_one_missing)`.

</details>

<details>

<summary>What if gdprApplies is false?</summary>

If `IABTCF_gdprApplies` is `0` (`false`), the SDK does not block ad requests. The only exception is an explicit opt-out through the DT FairBid GDPR API (`false`), which blocks ad requests.

</details>

## Consent Scenarios

The following table lists the SDK behavior for each consent scenario.

| Scenario                        | SDK Behavior                                                                                                                                                                                           | Log Message                                                                                                                                                                       |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Consent before start: granted   | The SDK starts and allows ad requests.                                                                                                                                                                 | `[FairBid][TCF] ALLOWED (purpose_one_consented)`, or `ALLOWED (gdpr_applies_not_present)` if no CMP value is stored.                                                              |
| Consent before start: denied    | The SDK does not start and does not make ad requests.                                                                                                                                                  | `[FairBid][TCF] BLOCKED (publisher_opt_out)` if denied through the DT FairBid GDPR API. `[FairBid][TCF] BLOCKED (purpose_one_missing)` if the TCF string lacks Purpose 1 consent. |
| Change after start: granted     | The SDK ignores the change and does not apply it later. If the SDK did not start because consent was denied, it stays blocked until the app restarts and starts with the new consent set before start. | None                                                                                                                                                                              |
| Change after start: denied      | The SDK ignores the change and does not apply it later. The SDK stays started and keeps allowing ad requests until the app restarts and starts with the new consent set before start.                  | None                                                                                                                                                                              |
| GDPR API call after start       | The call is a no-op. The SDK does not apply it later.                                                                                                                                                  | A warning that the call was ignored and that an app restart is required.                                                                                                          |
| Conflicting signals             | The most restrictive signal applies. The SDK does not start and does not make ad requests.                                                                                                             | `[FairBid][TCF] BLOCKED (publisher_opt_out)` or `[FairBid][TCF] BLOCKED (purpose_one_missing)`, depending on the blocking signal.                                                 |
| `IABTCF_gdprApplies` is `false` | The SDK does not block ad requests, unless the publisher opted out through the DT FairBid GDPR API.                                                                                                    | `[FairBid][TCF] ALLOWED (gdpr_does_not_apply)`                                                                                                                                    |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digitalturbine.com/dt-fairbid/fairbid-sdk/sdk-reference/gdpr.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
