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

{% hint style="warning" %}
We recommend against disabling the SDK if you simply want to add a custom notification opt-out to the settings of your app. You should instead:

* **iOS**: Direct users to iOS' settings.
* **Android**: Use Batch's native methods to disable notifications ([know more here](/developer/sdk/cordova/advanced/customizing-notifications.md#managing-ios-notification-display)).
  {% endhint %}

### Opting-out

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

```javascript
batch.optOut()
```

Opting out will:

* Prevent `batch.start()`
* Disable any network capability from the SDK
* Disable all In-App campaigns
* Make the Inbox module return an error immediately when used
* Make the SDK reject any `batch.user.editor()` modifications, even when saved
* Make the SDK reject calls to `batch.user.trackEvent()`, `batch.user.trackTransaction()`, `batch.user.trackLocation()` and any related methods

Even if you opt-in afterwards, data generated (such as user data or tracked events) **while** opted out WILL be lost.

You can also wipe the SDK installation data:

```javascript
batch.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 is not possible while the SDK hasn't started. Make sure you've called `batch.start()` beforehand.
{% endhint %}

### Disabling the SDK by default

The SDK can be disabled by default, requiring a call to `batch.optIn()` before `batch.start()` is allowed.

#### Android

Add a meta-data entry to your AndroidManifest's `<application>` tag:

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

For Cordova projects, this can be done in your application's `config.xml` (see [Android Manifest manipulation](/developer/sdk/cordova/advanced/android-manifest-manipulation.md) for more info):

```xml
<platform name="android">
  <config-file target="AndroidManifest.xml" parent="/manifest/application">
    <meta-data android:name="batch_opted_out_by_default" android:value="true" />
  </config-file>
</platform>
```

#### iOS

In your `Info.plist`, add a key called `BATCH_OPTED_OUT_BY_DEFAULT` with a `true` boolean value.

For Cordova projects, this can be done in your application's `config.xml`:

```xml
<platform name="ios">
  <config-file target="*-Info.plist" parent="BATCH_OPTED_OUT_BY_DEFAULT">
	    <true/>
  </config-file>
</platform>
```

### Opting-in

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

```java
batch.optIn()
batch.start()
```

{% hint style="info" %}
Even if you've already done so before opting-out, you are **required** to call `batch.start()` or the SDK won't work until the next start.
{% endhint %}


---

# 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/cordova/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.
