Skip to main content
Supported on: iOS SDK 1.0.61+
This guide walks you through configuring the AppDNA SDK, identifying users, and tracking your first event.

1. Configure the SDK

Initialize AppDNA as early as possible in your app lifecycle. For UIKit apps, place this in application(_: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.
Call AppDNA.configure(...) exactly once before using any other SDK methods. Calling it multiple times will result in undefined behavior.

Configuration Options

The AppDNAOptions struct lets you customize SDK behavior:

Environment

The Environment enum controls which backend environment the SDK targets:

Log Level

The LogLevel enum controls console log verbosity:
Use .debug during development to see all SDK activity. Switch to .warning or .none for production builds.

Billing Provider

The BillingProvider enum specifies which billing system to use:

2. Wait for Ready State

The SDK fetches remote configuration asynchronously. Use onReady to know when the SDK is fully initialized:

3. Identify Users

Once a user signs in, call identify 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 with track:
Events are batched and flushed automatically based on your flushInterval and batchSize settings.

5. Flush Events Manually

Force an immediate flush of all queued events:
This is useful before the app enters the background or when you need to ensure events are sent immediately. Control whether the SDK collects and sends analytics data:
When analytics is set to false, events are silently dropped and not queued. No data is sent to AppDNA servers until consent is granted.

7. Remote Config and Feature Flags

Retrieve server-side configuration values:
Check whether a feature flag is enabled:

8. Experiments

Get the variant assigned to a user for an experiment:
Check if the user is in a specific variant:

9. Session Data

Store cross-module session data that can be used in template interpolation across onboarding flows, paywalls, and in-app messages:
Session data values are accessible in Console-configured content using template syntax: {{session.selected_plan}}.

10. Reset on Logout

When a user signs out, call reset to clear the user identity and flush any remaining events:
This clears the identified user, generates a new anonymous ID, and flushes queued 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.