1. Configure the SDK
Initialize AppDNA as early as possible in your app lifecycle. For UIKit apps, place this inapplication(_:didFinishLaunchingWithOptions:). For SwiftUI apps, use the App initializer.
UIKit
SwiftUI
For background event uploads in SwiftUI apps, use
@UIApplicationDelegateAdaptor and call AppDNA.registerBackgroundTasks() in didFinishLaunchingWithOptions.If you don’t have your own Firebase: Keep
FirebaseApp.configure() as shown above — it initializes AppDNA’s Firebase instance.If you already use Firebase (Analytics, Crashlytics, Realtime Database): Remove the FirebaseApp.configure() call entirely and just call AppDNA.configure(...). The SDK automatically picks up GoogleService-Info-AppDNA.plist and creates its own named Firebase instance. Your existing Firebase setup is not affected.Configuration Options
TheAppDNAOptions struct lets you customize SDK behavior:
| Parameter | Type | Default | Description |
|---|---|---|---|
flushInterval | TimeInterval | 30 | Seconds between automatic event flushes |
batchSize | Int | 20 | Number of events to batch before flushing |
configTTL | TimeInterval | 3600 | Seconds before cached config is considered stale |
logLevel | LogLevel | .warning | Verbosity of SDK console logs |
billingProvider | BillingProvider | .storeKit2 | Billing integration to use |
Environment
TheEnvironment enum controls which backend environment the SDK targets:
| Value | Description |
|---|---|
.production | Production API and configuration |
.sandbox | Sandbox API for testing |
Log Level
TheLogLevel enum controls console log verbosity:
| Value | Description |
|---|---|
.none | No logging |
.error | Errors only |
.warning | Errors and warnings |
.info | Errors, warnings, and info |
.debug | All messages including debug |
Use
.debug during development to see all SDK activity. Switch to .warning or .none for production builds.Billing Provider
TheBillingProvider enum specifies which billing system to use:
| Value | Description |
|---|---|
.storeKit2 | Native StoreKit 2 (default) |
.revenueCat | RevenueCat integration |
.adapty(apiKey:) | Adapty integration with your API key |
.none | Disable billing module |
2. Wait for Ready State
The SDK fetches remote configuration asynchronously. UseonReady to know when the SDK is fully initialized:
3. Identify Users
Once a user signs in, callidentify to associate events with their user ID:
Traits are merged with any previously set traits. You do not need to pass all traits on every call — only the ones that have changed.
4. Track Events
Track user actions withtrack:
flushInterval and batchSize settings.
5. Flush Events Manually
Force an immediate flush of all queued events:6. Set User Consent
Control whether the SDK collects and sends analytics data:7. Remote Config and Feature Flags
Retrieve server-side configuration values:8. Experiments
Get the variant assigned to a user for an experiment:9. Session Data
Store cross-module session data that can be used in template interpolation across onboarding flows, paywalls, and in-app messages:{{session.selected_plan}}.
10. Reset on Logout
When a user signs out, callreset to clear the user identity and flush any remaining events:
You now have the SDK configured, user identification, event tracking, remote config, experiments, and session data working. Continue to the module-specific guides for Push Notifications, Billing, Onboarding, and Paywalls.

