Skip to main content
The SDK must be initialized before tracking events or accessing cohort data. Initialization is asynchronous and should happen early in your app lifecycle.

Basic Initialization

Configuration Options

The Options class accepts several configuration parameters:

Required Parameters

Optional Configuration

Log Modes

Control what the SDK logs to the console:

Where to Initialize

UIKit - AppDelegate

SwiftUI - App Struct

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:
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. App Tracking Transparency and IDFA are available on tvOS from version 14.5 onwards.

Best Practices

  • 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

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
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)
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