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.
How to Configure Opt-out
Opt-out can be configured in two ways:
Configure at initialization: Set
optOutTrackingin the SDK initialization config.Configure at runtime: Change the opt-out state while the app is running using the
setOptOutTracking()method.
State Management
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.
Persistence Management
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)
Last updated