Supported on: iOS SDK 1.0.61+
This is the complete reference for all public methods, properties, types, and delegate protocols in the AppDNA iOS SDK.
Core Methods
| Method | Signature | Description |
|---|
configure | AppDNA.configure(apiKey: String, environment: Environment, options: AppDNAOptions?) | Initialize the SDK. Call once at app launch. |
identify | AppDNA.identify(userId: String, traits: [String: Any]?) | Associate events with a user identity. |
reset | AppDNA.reset() | Clear user identity and flush events. Call on logout. |
track | AppDNA.track(event: String, properties: [String: Any]?) | Track a custom event with optional properties. |
flush | AppDNA.flush() | Force an immediate flush of all queued events. |
onReady | AppDNA.onReady(_ callback: @escaping () -> Void) | Register a callback for when the SDK is fully initialized. |
shutdown | AppDNA.shutdown() | Shut down the SDK, flush events, and release resources. |
setLogLevel | AppDNA.setLogLevel(_ level: LogLevel) | Change the SDK log level at runtime. |
setConsent | AppDNA.setConsent(analytics: Bool) | Set analytics consent. When false, events are dropped silently. |
Session Data Methods
| Method | Signature | Description |
|---|
setSessionData | AppDNA.setSessionData(key: String, value: Any) | Store a key-value pair in the session data store. |
getSessionData | AppDNA.getSessionData(key: String) -> Any? | Retrieve a session data value by key. |
clearSessionData | AppDNA.clearSessionData() | Clear all app-defined session data. |
getLocationData | AppDNA.getLocationData(fieldId: String) -> LocationData? | Get structured location data from an onboarding location field. Returns city, state, country, coordinates, timezone. |
Config Methods
| Method | Signature | Description |
|---|
getRemoteConfig | AppDNA.getRemoteConfig(key: String) -> Any? | Get a remote config value by key. |
forceRefreshConfig | AppDNA.forceRefreshConfig() | Force an immediate refresh of remote configuration. |
isFeatureEnabled | AppDNA.isFeatureEnabled(flag: String) -> Bool | Check if a feature flag is enabled. |
Experiment Methods
| Method | Signature | Description |
|---|
getExperimentVariant | AppDNA.getExperimentVariant(experimentId: String) -> String? | Get the assigned variant for an experiment. |
isInVariant | AppDNA.isInVariant(experimentId: String, variantId: String) -> Bool | Check if the user is in a specific variant. |
getExperimentConfig | AppDNA.getExperimentConfig(experimentId: String, key: String) -> Any? | Get a specific config value for an experiment variant. |
Push Methods
| Method | Signature | Description |
|---|
registerForPush | AppDNA.registerForPush() async -> Bool | Request push permission and register for remote notifications. |
setPushToken | AppDNA.setPushToken(_ deviceToken: Data) | Set the APNs device token manually. |
setPushPermission | AppDNA.setPushPermission(granted: Bool) | Update the push permission status. |
trackPushDelivered | AppDNA.trackPushDelivered(pushId: String) | Track that a push notification was delivered. |
trackPushTapped | AppDNA.trackPushTapped(pushId: String, action: String?) | Track that a push notification was tapped. |
Presentation Methods
| Method | Signature | Description |
|---|
presentOnboarding | AppDNA.presentOnboarding(flowId: String?, from: UIViewController, delegate: AppDNAOnboardingDelegate?) -> Bool | Present an onboarding flow. Returns false if config unavailable. |
presentPaywall | AppDNA.presentPaywall(id: String, from: UIViewController, context: PaywallContext?, delegate: AppDNAPaywallDelegate?) | Present a paywall by ID. |
Web Entitlements
| Member | Signature | Description |
|---|
webEntitlement | AppDNA.webEntitlement: WebEntitlement? | The current web entitlement, if any. |
onWebEntitlementChanged | AppDNA.onWebEntitlementChanged(_ callback: @escaping (WebEntitlement?) -> Void) | Register a callback for web entitlement changes. |
Deep Links
| Method | Signature | Description |
|---|
checkDeferredDeepLink | AppDNA.checkDeferredDeepLink(completion: @escaping (DeferredDeepLink?) -> Void) | Check for a deferred deep link from install attribution. |
Module Namespaces
Access module-specific functionality through these properties on the AppDNA singleton:
| Property | Type | Description |
|---|
AppDNA.pushModule | PushModule | Push notification registration, tokens, and delegates |
AppDNA.billing | BillingModule | Products, purchases, entitlements, and restore |
AppDNA.onboarding | OnboardingModule | Server-driven onboarding flow presentation |
AppDNA.paywall | PaywallModule | Server-driven paywall presentation |
AppDNA.remoteConfig | RemoteConfigModule | Remote configuration access |
AppDNA.features | FeaturesModule | Feature flag evaluation |
AppDNA.experiments | ExperimentsModule | Experiment variant assignment |
AppDNA.inAppMessages | InAppMessagesModule | In-app message display |
AppDNA.surveys | SurveysModule | User survey presentation |
AppDNA.deepLinks | DeepLinksModule | Deep link and deferred deep link handling |
Delegate Protocols
AppDNAPushDelegate
protocol AppDNAPushDelegate {
func onPushTokenRegistered(token: String)
func onPushReceived(notification: PushPayload, inForeground: Bool)
func onPushTapped(notification: PushPayload, actionId: String?)
}
AppDNABillingDelegate
protocol AppDNABillingDelegate {
func onPurchaseCompleted(productId: String, transaction: TransactionInfo)
func onPurchaseFailed(productId: String, error: Error)
func onEntitlementsChanged(entitlements: [Entitlement])
func onRestoreCompleted(restoredProducts: [String])
}
AppDNAOnboardingDelegate
protocol AppDNAOnboardingDelegate {
func onOnboardingStarted(flowId: String)
func onOnboardingStepChanged(flowId: String, stepId: String, stepIndex: Int, totalSteps: Int)
func onOnboardingCompleted(flowId: String, responses: [String: Any])
func onOnboardingDismissed(flowId: String, atStep: Int)
// Async hooks (optional)
func onBeforeStepAdvance(flowId: String, fromStepId: String, stepIndex: Int, stepType: String, responses: [String: Any], stepData: [String: Any]?) async -> StepAdvanceResult
func onBeforeStepRender(flowId: String, stepId: String, stepIndex: Int, stepType: String, responses: [String: Any]) async -> StepConfigOverride?
}
AppDNAPaywallDelegate
protocol AppDNAPaywallDelegate {
func onPaywallPresented(paywallId: String)
func onPaywallAction(paywallId: String, action: PaywallAction)
func onPaywallPurchaseStarted(paywallId: String, productId: String)
func onPaywallPurchaseCompleted(paywallId: String, productId: String, transaction: TransactionInfo)
func onPaywallPurchaseFailed(paywallId: String, error: Error)
func onPaywallDismissed(paywallId: String)
func onPromoCodeSubmit(paywallId: String, code: String, completion: @escaping (Bool) -> Void)
func onPostPurchaseDeepLink(paywallId: String, url: String)
func onPostPurchaseNextStep(paywallId: String)
func onPaywallRestoreStarted(paywallId: String)
func onPaywallRestoreCompleted(paywallId: String, productIds: [String])
func onPaywallRestoreFailed(paywallId: String, error: Error)
}
AppDNAInAppMessageDelegate
public protocol AppDNAInAppMessageDelegate: AnyObject {
func onMessageShown(messageId: String, trigger: String)
func onMessageAction(messageId: String, action: String, data: [String: Any]?)
func onMessageDismissed(messageId: String)
func shouldShowMessage(messageId: String) -> Bool
}
AppDNASurveyDelegate
protocol AppDNASurveyDelegate {
func onSurveyPresented(surveyId: String)
func onSurveyCompleted(surveyId: String, responses: [SurveyResponse])
func onSurveyDismissed(surveyId: String)
}
AppDNADeepLinkDelegate
public protocol AppDNADeepLinkDelegate: AnyObject {
func onDeepLinkReceived(url: URL, params: [String: String])
}
Key Types
AppDNAOptions
struct AppDNAOptions {
var flushInterval: TimeInterval // Default: 30
var batchSize: Int // Default: 20
var configTTL: TimeInterval // Default: 3600
var logLevel: LogLevel // Default: .warning
var billingProvider: BillingProvider // Default: .storeKit2
}
Environment
enum Environment {
case production
case sandbox
}
LogLevel
enum LogLevel {
case none
case error
case warning
case info
case debug
}
BillingProvider
enum BillingProvider {
case storeKit2
case revenueCat
case adapty(apiKey: String)
case none
}
PaywallContext
struct PaywallContext {
var placement: String
var experiment: String?
var variant: String?
}
OnboardingContext
struct OnboardingContext {
var source: String?
var campaign: String?
var referrer: String?
var userProperties: [String: Any]?
var experimentOverrides: [String: String]?
}
PushPayload
struct PushPayload {
var pushId: String
var title: String
var body: String
var imageUrl: String?
var data: [String: Any]?
var action: PushAction?
}
PushAction
struct PushAction {
var type: String
var value: String
}
TransactionInfo
struct TransactionInfo {
var transactionId: String
var productId: String
var purchaseDate: Date
var environment: String
}
ProductInfo
struct ProductInfo {
var id: String
var displayName: String
var description: String
var price: Decimal
var displayPrice: String
var subscription: SubscriptionInfo?
}
Entitlement
struct Entitlement {
var identifier: String
var isActive: Bool
var expiresAt: Date?
var productId: String
}
WebEntitlement
struct WebEntitlement {
var identifier: String
var isActive: Bool
var source: String
var expiresAt: Date?
}
DeferredDeepLink
struct DeferredDeepLink {
var screen: String
var params: [String: String]
var visitorId: String
}
PaywallAction
enum PaywallAction {
case ctaTapped
case featureSelected
case planChanged
case linkTapped
case custom
}
DismissReason
enum DismissReason {
case purchased
case dismissed
case tappedOutside
case programmatic
}
StepAdvanceResult
enum StepAdvanceResult {
case proceed
case proceedWithData([String: Any])
case block(message: String)
case skipTo(stepId: String)
case skipToWithData(stepId: String, data: [String: Any])
}
StepConfigOverride
struct StepConfigOverride {
var fieldDefaults: [String: Any]?
var title: String?
var subtitle: String?
var ctaText: String?
var layoutOverrides: [String: Any]?
}
enum FormFieldType {
case text, textarea, number, email, phone
case date, time, datetime
case select, slider, toggle, stepper, segmented
case location
}
Server-Driven Screens
| Method | Signature | Description |
|---|
showScreen | AppDNA.showScreen(_ screenId: String, completion: ((ScreenResult) -> Void)?) | Present a server-driven screen by ID. |
showFlow | AppDNA.showFlow(_ flowId: String, completion: ((FlowResult) -> Void)?) | Present a multi-screen flow by ID. |
dismissScreen | AppDNA.dismissScreen() | Dismiss the currently presented screen or flow. |
enableNavigationInterception | AppDNA.enableNavigationInterception(forScreens: [String]?) | Enable automatic screen injection between navigations. Pass nil for all screens. |
disableNavigationInterception | AppDNA.disableNavigationInterception() | Disable navigation interception. |
previewScreen | AppDNA.previewScreen(json: String, completion: ((ScreenResult) -> Void)? = nil) | Preview a screen from raw JSON config. (DEBUG builds only) |
screenDelegate | AppDNA.screenDelegate: AppDNAScreenDelegate? | Set a delegate for screen lifecycle callbacks. |
isConsentGranted | AppDNA.isConsentGranted() -> Bool | Check if analytics consent has been granted. |
getUserTraits | AppDNA.getUserTraits() -> [String: Any] | Get the current user traits set via identify(). |
AppDNAScreenDelegate
protocol AppDNAScreenDelegate {
func onScreenPresented(screenId: String)
func onScreenDismissed(screenId: String, result: ScreenResult)
func onFlowCompleted(flowId: String, result: FlowResult)
func onScreenAction(screenId: String, action: SectionAction) -> Bool
}
ScreenResult
struct ScreenResult {
var dismissed: Bool
var responses: [String: Any]
}
FlowResult
struct FlowResult {
var completed: Bool
var screensViewed: Int
var responses: [String: Any]
}
SectionAction
struct SectionAction {
var sectionId: String
var actionType: String
var data: [String: Any]?
}
Properties
| Property | Type | Description |
|---|
AppDNA.sdkVersion | String | The current SDK version string (e.g., “1.0.0”). |
AppDNA.currentBundleVersion | Int | The current config bundle version number. |
AppDNA.configUpdated | Notification.Name | Notification posted when remote config is updated. |