Skip to main content
This is the complete reference for all public methods, properties, types, and delegate protocols in the AppDNA iOS SDK.

Core Methods

MethodSignatureDescription
configureAppDNA.configure(apiKey: String, environment: Environment, options: AppDNAOptions?)Initialize the SDK. Call once at app launch.
identifyAppDNA.identify(userId: String, traits: [String: Any]?)Associate events with a user identity.
resetAppDNA.reset()Clear user identity and flush events. Call on logout.
trackAppDNA.track(event: String, properties: [String: Any]?)Track a custom event with optional properties.
flushAppDNA.flush()Force an immediate flush of all queued events.
onReadyAppDNA.onReady(_ callback: @escaping () -> Void)Register a callback for when the SDK is fully initialized.
shutdownAppDNA.shutdown()Shut down the SDK, flush events, and release resources.
setLogLevelAppDNA.setLogLevel(_ level: LogLevel)Change the SDK log level at runtime.
setConsentAppDNA.setConsent(analytics: Bool)Set analytics consent. When false, events are dropped silently.

Session Data Methods

MethodSignatureDescription
setSessionDataAppDNA.setSessionData(key: String, value: Any)Store a key-value pair in the session data store.
getSessionDataAppDNA.getSessionData(key: String) -> Any?Retrieve a session data value by key.
clearSessionDataAppDNA.clearSessionData()Clear all app-defined session data.
getLocationDataAppDNA.getLocationData(fieldId: String) -> LocationData?Get structured location data from an onboarding location field. Returns city, state, country, coordinates, timezone.

Config Methods

MethodSignatureDescription
getRemoteConfigAppDNA.getRemoteConfig(key: String) -> Any?Get a remote config value by key.
forceRefreshConfigAppDNA.forceRefreshConfig()Force an immediate refresh of remote configuration.
isFeatureEnabledAppDNA.isFeatureEnabled(flag: String) -> BoolCheck if a feature flag is enabled.

Experiment Methods

MethodSignatureDescription
getExperimentVariantAppDNA.getExperimentVariant(experimentId: String) -> String?Get the assigned variant for an experiment.
isInVariantAppDNA.isInVariant(experimentId: String, variantId: String) -> BoolCheck if the user is in a specific variant.
getExperimentConfigAppDNA.getExperimentConfig(experimentId: String, key: String) -> Any?Get a specific config value for an experiment variant.

Push Methods

MethodSignatureDescription
registerForPushAppDNA.registerForPush() async -> BoolRequest push permission and register for remote notifications.
setPushTokenAppDNA.setPushToken(_ deviceToken: Data)Set the APNs device token manually.
setPushPermissionAppDNA.setPushPermission(granted: Bool)Update the push permission status.
trackPushDeliveredAppDNA.trackPushDelivered(pushId: String)Track that a push notification was delivered.
trackPushTappedAppDNA.trackPushTapped(pushId: String, action: String?)Track that a push notification was tapped.

Presentation Methods

MethodSignatureDescription
presentOnboardingAppDNA.presentOnboarding(flowId: String?, from: UIViewController, delegate: AppDNAOnboardingDelegate?) -> BoolPresent an onboarding flow. Returns false if config unavailable.
presentPaywallAppDNA.presentPaywall(id: String, from: UIViewController, context: PaywallContext?, delegate: AppDNAPaywallDelegate?)Present a paywall by ID.

Web Entitlements

MemberSignatureDescription
webEntitlementAppDNA.webEntitlement: WebEntitlement?The current web entitlement, if any.
onWebEntitlementChangedAppDNA.onWebEntitlementChanged(_ callback: @escaping (WebEntitlement?) -> Void)Register a callback for web entitlement changes.
MethodSignatureDescription
checkDeferredDeepLinkAppDNA.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:
PropertyTypeDescription
AppDNA.pushModulePushModulePush notification registration, tokens, and delegates
AppDNA.billingBillingModuleProducts, purchases, entitlements, and restore
AppDNA.onboardingOnboardingModuleServer-driven onboarding flow presentation
AppDNA.paywallPaywallModuleServer-driven paywall presentation
AppDNA.remoteConfigRemoteConfigModuleRemote configuration access
AppDNA.featuresFeaturesModuleFeature flag evaluation
AppDNA.experimentsExperimentsModuleExperiment variant assignment
AppDNA.inAppMessagesInAppMessagesModuleIn-app message display
AppDNA.surveysSurveysModuleUser survey presentation
AppDNA.deepLinksDeepLinksModuleDeep 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)
    func onPostPurchaseDeepLink(paywallId: String, deepLink: String)
    func onPostPurchaseNextStep(paywallId: String, stepId: String)
}

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?
}
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]?
}

FormFieldType

enum FormFieldType {
    case text, textarea, number, email, phone
    case date, time, datetime
    case select, slider, toggle, stepper, segmented
    case location
}

Server-Driven Screens

MethodSignatureDescription
showScreenAppDNA.showScreen(_ screenId: String, completion: ((ScreenResult) -> Void)?)Present a server-driven screen by ID.
showFlowAppDNA.showFlow(_ flowId: String, completion: ((FlowResult) -> Void)?)Present a multi-screen flow by ID.
dismissScreenAppDNA.dismissScreen()Dismiss the currently presented screen or flow.
enableNavigationInterceptionAppDNA.enableNavigationInterception(forScreens: [String]?)Enable automatic screen injection between navigations. Pass nil for all screens.
disableNavigationInterceptionAppDNA.disableNavigationInterception()Disable navigation interception.
previewScreenAppDNA.previewScreen(json: String, completion: ((ScreenResult) -> Void)? = nil)Preview a screen from raw JSON config. (DEBUG builds only)
screenDelegateAppDNA.screenDelegate: AppDNAScreenDelegate?Set a delegate for screen lifecycle callbacks.
isConsentGrantedAppDNA.isConsentGranted() -> BoolCheck if analytics consent has been granted.
getUserTraitsAppDNA.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

PropertyTypeDescription
AppDNA.sdkVersionStringThe current SDK version string (e.g., “1.0.0”).
AppDNA.currentBundleVersionIntThe current config bundle version number.
AppDNA.configUpdatedNotification.NameNotification posted when remote config is updated.