SDK Opt-out
Last updated
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.
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.
The SDK manages the opt-out state only in memory. When the app restarts, it resets to the value set in the initialization config.
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.
To persist a user's opt-out setting across app restarts, you must manage it persistently in your app.
Recommended Implementation Flow
When a user changes their opt-out setting, save the state to the app's persistent storage.
When the app starts, read the opt-out state from storage and set it in the SDK initialization config.
When the state changes while the app is running, update both the storage and the SDK.
Persistent Storage Examples by Platform
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