# SDK opt-out (e.g. GDPR)

If you plan to send personal user data and have to comply with EU's GDPR, any other data privacy law or simply want to give your users more control regarding their privacy, these methods will help you plug your consent screen to Batch.

There are two SDK operation modes:

* **SDK enabled by default**, opting-out required via an explicit method call: this is the default mode.
* **SDK disabled by default**, opting-in required

{% hint style="warning" %}
On iOS, disabling the SDK won't disable push notifications if Batch already has a valid token.
{% endhint %}

### Opting-out

In order to opt-out from SDK, simply call:

```dart
await Batch.instance.optOut()
```

Opting out will:

* Prevent Batch from starting
* Disable any network capability from the SDK
* Disable all In-App campaigns
* Make the Inbox module return an error immediately
* Make any call to `BatchProfileAttributeEditor.save()` do nothing
* Make any `trackEvent` methods from BatchProfile ineffective

{% hint style="info" %}
Even if you opt-in afterwards, data generated (such as user data or tracked events) **while** opted out WILL be lost.
{% endhint %}

You can also wipe the SDK installation data:

```dart
await Batch.instance.optOutAndWipeData()
```

This will wipe the data locally and request a remote data removal for the matching Installation ID and its associated data.\
Any user-level data associated with the Custom User ID (if any) set via our server APIs will **not** be deleted. However, the Installation ID <> Custom User ID association will be, effectively logging the user out before deleting their installation data.\
Sending notifications to this user using their Advertising ID (via the Transactional API or a Custom Audience) will not be possible for a month.

{% hint style="info" %}
Opting out or wiping data is not possible while the SDK hasn't started. If you're opted out and want to delete user data, please temporarily opt-in so that Batch can send the deletion request to the servers.
{% endhint %}

### Disabling the SDK by default

In order to disable the SDK by default, you will need to modify your `Info.plist` or `AndroidManifest.xml`:

* On iOS, you need to add a key called `BATCH_OPTED_OUT_BY_DEFAULT` with a `true` boolean value to your Info.plist.
* On Android, please add a meta-data entry to your AndroidManifest's `<application>` tag:

{% code title="AndroidManifest.xml" %}

```xml
<meta-data android:name="batch_opted_out_by_default" android:value="true" />
```

{% endcode %}

### Opting-in

Once you've opted-out (either programmatically, or by default), you can re-enable the SDK by calling the following:

```dart
Batch.instance.optIn()
```

### Reading opted-out status

If you need to know whether your users are opted-out from the sdk you can use:

```dart
await Batch.instance.isOptedOut()
```


---

# 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://doc.batch.com/developer/sdk/flutter/data-privacy/opt-out.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.
