Consent
The Datafly mobile SDKs support category-based consent management. Set consent categories to control which types of data processing are permitted.
Setting consent
iOS (Swift)
Datafly.shared.setConsent(["analytics": true, "marketing": false, "functional": true])Android (Kotlin)
Datafly.setConsent(mapOf(
"analytics" to true,
"marketing" to false,
"functional" to true
))React Native
DataflySignal.setConsent({ analytics: true, marketing: false, functional: true });How it works
- Consent categories are stored locally (UserDefaults on iOS, SharedPreferences on Android)
- Consent state is restored automatically on SDK init
- The
consent.categoriesobject is attached to every event - The server-side event processor uses consent to gate which vendors receive the event
Reading consent
// iOS
let currentConsent = Datafly.shared.consent // [String: Bool]?
// Android
val currentConsent = Datafly.consent // Map<String, Boolean>?Category names
Category names are flexible — use whatever categories your consent implementation requires. Common categories:
| Category | Description |
|---|---|
analytics | Analytics and performance tracking |
marketing | Marketing and advertising |
functional | Functional features (e.g., chat widgets) |
personalization | Content personalisation |
iOS App Tracking Transparency
On iOS, if you need to track users across apps (IDFA), you must request ATT permission. This is separate from the consent categories:
import AppTrackingTransparency
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .authorized:
// User granted tracking permission
Datafly.shared.setConsent(["analytics": true, "marketing": true])
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
Datafly.shared.setAdvertisingId(idfa, enabled: true)
case .denied, .restricted:
Datafly.shared.setConsent(["analytics": true, "marketing": false])
default:
break
}
}The Datafly SDK continues to collect events regardless of consent state. Consent categories are attached to each event and enforced server-side during pipeline processing. This means you can update consent retroactively without losing events.
Consent on reset
Calling reset() does not clear consent state. Consent is considered a user preference that persists across sessions, not part of the user identity.