The SDK must be initialized before tracking events or accessing cohort data. Initialization is asynchronous and should happen early in your app lifecycle.
The Permutive SDK assumes consent has been obtained before initialization. If your app requires user consent for tracking, complete your consent flow before calling start(with:).
The SDK does not call Apple’s App Tracking Transparency (ATT) framework. If you need ATT consent:
Copy
Ask AI
import AppTrackingTransparencyfunc requestConsentThenInitialize() { if #available(iOS 14, *) { ATTrackingManager.requestTrackingAuthorization { status in switch status { case .authorized: self.initializePermutive() case .denied, .restricted: // Handle accordingly - you may still initialize // Permutive without IDFA tracking self.initializePermutive() case .notDetermined: break @unknown default: break } } } else { initializePermutive() }}
IDFA is not required. Permutive works effectively without IDFA. Consider using identifierForVendor or hashed email addresses instead. See IDFA Provider for details.
The SDK provides properties to check its current state:
Copy
Ask AI
// Get the current user ID (available after initialization)let userId = Permutive.shared.currentUserId// Check current cohortslet cohorts = Permutive.shared.cohorts
Permutive.shared.start(with: options) { error in if let error = error { // Log the error for debugging print("Permutive initialization failed: \(error.localizedDescription)") // Optionally report to your error tracking service // ErrorTracker.report(error) // The app can continue without Permutive // SDK calls will be no-ops or return empty data return } // SDK is ready - proceed with tracking print("Permutive ready, user ID: \(Permutive.shared.currentUserId)")}
tvOS Note: The initialization process is identical on tvOS. The SDK automatically handles platform differences. IDFA and App Tracking Transparency are not available on tvOS.