Consent

The Datafly mobile SDKs support category-based consent management. Set consent categories to control which types of data processing are permitted.

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

  1. Consent categories are stored locally (UserDefaults on iOS, SharedPreferences on Android)
  2. Consent state is restored automatically on SDK init
  3. The consent.categories object is attached to every event
  4. The server-side event processor uses consent to gate which vendors receive the event
// 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:

CategoryDescription
analyticsAnalytics and performance tracking
marketingMarketing and advertising
functionalFunctional features (e.g., chat widgets)
personalizationContent 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.

Calling reset() does not clear consent state. Consent is considered a user preference that persists across sessions, not part of the user identity.