For the complete documentation index, see llms.txt. This page is also available as Markdown.

SDK Opt-out

Opt-out is a feature that stops collecting a user's data. It is used to comply with privacy regulations or to respond to a user's request to stop data collection.

Even in an opt-out state, SDK features such as A/B Tests, Feature Flags, and In-App Messages continue to work normally.

How to Configure Opt-out

Opt-out can be configured in two ways:

  • Configure at initialization: Set optOutTracking in the SDK initialization config.

  • Configure at runtime: Change the opt-out state while the app is running using the setOptOutTracking() method.

State Management

The opt-out state changed via setOptOutTracking() is not persisted when the app restarts. When the app restarts, the optOutTracking value set in HackleConfig is applied.

Persistence Management

To persist a user's opt-out setting across app restarts, you must manage it persistently in your app.

Recommended Implementation Flow

  1. When a user changes their opt-out setting, save the state to the app's persistent storage.

  2. When the app starts, read the opt-out state from storage and set it in the SDK initialization config.

  3. When the state changes while the app is running, update both the storage and the SDK.

Persistent Storage Examples by Platform

Platform
Persistent Storage

iOS

UserDefaults

Android

SharedPreferences

JavaScript / React

localStorage

React Native

AsyncStorage or MMKV

Flutter

SharedPreferences (shared_preferences package)

For specific usage of the opt-out API and code examples for persistence management, refer to each SDK's opt-out documentation.

Last updated