The SDK must be initialized before tracking events or accessing cohort data. Initialization is asynchronous and should happen early in your app lifecycle.Documentation Index
Fetch the complete documentation index at: https://docs.permutive.com/llms.txt
Use this file to discover all available pages before exploring further.
Basic Initialization
Configuration Options
TheOptions class accepts several configuration parameters:
Required Parameters
| Parameter | Type | Description |
|---|---|---|
apiKey | String | Your Permutive API key |
organisationId | String | Your Permutive organisation ID |
workspaceId | String | Your Permutive workspace ID |
Optional Configuration
Log Modes
Control what the SDK logs to the console:| Mode | Description |
|---|---|
LogMode.none | No logging (default for production) |
LogMode.all | All messages (recommended for development) |
LogMode.info | Informational messages only |
LogMode.error | Error messages only |
Where to Initialize
UIKit - AppDelegate
SwiftUI - App Struct
Consent Considerations
The SDK does not call Apple’s App Tracking Transparency (ATT) framework. If you need ATT consent:IDFA is not required. Permutive works effectively without IDFA. Consider using
identifierForVendor or hashed email addresses instead. See IDFA Provider for details.Initialization with Context
You can provide initial context during initialization:Checking Initialization Status
The SDK provides properties to check its current state:Error Handling
Handle initialization errors appropriately:tvOS Considerations
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.
Best Practices
- Do
- Don't
- Initialize as early as possible in the app lifecycle
- Handle initialization errors gracefully
- Complete consent flows before initialization
- Enable debug logging during development
- Store credentials securely (consider using a configuration file or build settings)
Troubleshooting
Initialization fails silently
Initialization fails silently
Problem: No error, but SDK doesn’t seem to work.Solutions:
- Enable debug logging:
options.logModes = LogMode.all - Check credentials are correct
- Verify network connectivity
Invalid credentials error
Invalid credentials error
Problem: Initialization fails with credential error.Solutions:
- Verify API key, organization ID, and workspace ID from your dashboard
- Check for extra whitespace or newlines in credential strings
- Ensure credentials match the correct environment (staging vs production)
SDK not ready when tracking
SDK not ready when tracking
Problem: Events tracked before initialization completes are lost.Solution: Wait for the completion callback before tracking:
Next Steps
Verification
Verify your integration is working
Page Tracking
Track page views and engagement