Skip to main content
Supported on: Android SDK 1.0.33+
This page provides a comprehensive reference for all public methods, properties, and types in the AppDNA Android SDK.

Core Methods

Methods available directly on the AppDNA object.
MethodSignatureDescription
configureconfigure(context: Context, apiKey: String, environment: Environment, options: AppDNAOptions)Initialize the SDK. Call once in Application.onCreate().
identifyidentify(userId: String, traits: Map<String, Any>?)Associate events with a user ID and optional traits.
resetreset()Clear user identity, experiment exposures, in-session message/survey state, and stop entitlement observers. Call on logout.
tracktrack(event: String, properties: Map<String, Any>?)Track a named event with optional properties.
flushflush()Force an immediate flush of all queued events.
onReadyonReady(callback: () -> Unit)Register a callback for when the SDK is fully initialized.
shutdownshutdown()Gracefully shut down the SDK and release resources.
setLogLevelsetLogLevel(level: String)Change log verbosity at runtime. Accepts "none", "error", "warning", "info", "debug".
setLogLevelsetLogLevel(level: LogLevel)Same as above, but takes the typed LogLevel enum.
setConsentsetConsent(analytics: Boolean)Enable or disable analytics data collection.

Session Data Methods

MethodSignatureDescription
setSessionDatasetSessionData(key: String, value: Any)Store a key-value pair in the session data store.
getSessionDatagetSessionData(key: String): Any?Retrieve a session data value by key.
clearSessionDataclearSessionData()Clear all app-defined session data.
getLocationDatagetLocationData(fieldId: String): LocationData?Get structured location data from an onboarding location field. Returns city, state, country, coordinates, timezone.

Config Methods

MethodSignatureReturnsDescription
getRemoteConfiggetRemoteConfig(key: String)Any?Retrieve a remote configuration value by key.
forceRefreshConfigforceRefreshConfig()UnitForce an immediate refresh of remote configuration.
isFeatureEnabledisFeatureEnabled(flag: String)BooleanCheck whether a feature flag is enabled.

Experiment Methods

MethodSignatureReturnsDescription
getExperimentVariantgetExperimentVariant(experimentId: String)String?Get the assigned variant for an experiment.
isInVariantisInVariant(experimentId: String, variantId: String)BooleanCheck if the user is in a specific experiment variant.
getExperimentConfiggetExperimentConfig(experimentId: String, key: String)Any?Get a configuration value for a specific experiment.

Push Methods

MethodSignatureDescription
setPushTokensetPushToken(token: String)Register the FCM push token.
onNewPushTokenonNewPushToken(token: String)Alternative method to register the FCM push token.
setPushPermissionsetPushPermission(granted: Boolean)Report push notification permission status.
trackPushDeliveredtrackPushDelivered(pushId: String)Track that a push notification was delivered.
trackPushTappedtrackPushTapped(pushId: String, action: String?)Track that a push notification was tapped.
There is no registerForPush() helper on Android. Push permission (POST_NOTIFICATIONS) is a runtime permission on Android 13+ and is requested through AppDNA.push.requestPermission(activity). See the Push guide for the full setup.

Presentation Methods

MethodSignatureReturnsDescription
presentOnboardingpresentOnboarding(activity: Activity, flowId: String?, listener: AppDNAOnboardingDelegate?)BooleanPresent an onboarding flow. Returns whether it was presented.
presentPaywallpresentPaywall(activity: Activity, id: String, context: PaywallContext?, listener: AppDNAPaywallDelegate?)UnitPresent a paywall by ID.
paywall.presentByPlacementpresentByPlacement(activity: Activity, placement: String, context: PaywallContext?)UnitPresent whichever paywall the audience rules for placement resolve to.

Web Entitlements

MemberTypeDescription
webEntitlementWebEntitlement? (property)The current web entitlement, if any.
onWebEntitlementChanged(callback: (WebEntitlement?) -> Unit)Register a listener for web entitlement changes.
MethodSignatureDescription
checkDeferredDeepLinkcheckDeferredDeepLink(callback: (DeferredDeepLink?) -> Unit)Check for a deferred deep link and invoke the callback with the result.

Module Namespaces

The SDK exposes the following module namespaces for direct access:
NamespaceTypeDescription
AppDNA.pushPushModulePush notification management
AppDNA.billingBillingModuleBilling and subscription management
AppDNA.onboardingOnboardingModuleOnboarding flow presentation
AppDNA.paywallPaywallModulePaywall presentation
AppDNA.remoteConfigRemoteConfigModuleRemote configuration access
AppDNA.featuresFeaturesModuleFeature flag access
AppDNA.experimentsExperimentsModuleExperiment variant access
AppDNA.inAppMessagesInAppMessagesModuleIn-app message management
AppDNA.surveysSurveysModuleSurvey management
AppDNA.deepLinksDeepLinksModuleDeep link handling
Server-driven screens are accessed via top-level methods on AppDNA (showScreen, showFlow, dismissScreen, etc.) and the AppDNA.screenDelegate property — there is no AppDNA.screens module namespace.

Delegate Interfaces

AppDNAPushDelegate

interface AppDNAPushDelegate {
    fun onPushTokenRegistered(token: String)
    fun onPushReceived(notification: PushPayload, inForeground: Boolean)
    fun onPushTapped(notification: PushPayload, actionId: String?)
}

AppDNABillingDelegate

interface AppDNABillingDelegate {
    fun onPurchaseCompleted(productId: String, transaction: TransactionInfo) {}
    fun onPurchaseFailed(productId: String, error: Throwable) {}
    fun onEntitlementsChanged(entitlements: List<Entitlement>) {}
    fun onRestoreCompleted(restoredProducts: List<String>) {}
    fun onBillingUnavailable() {}
}

AppDNAOnboardingDelegate

interface AppDNAOnboardingDelegate {
    fun onOnboardingStarted(flowId: String)
    fun onOnboardingStepChanged(flowId: String, stepId: String, stepIndex: Int, totalSteps: Int)
    fun onOnboardingCompleted(flowId: String, responses: Map<String, Any>)
    fun onOnboardingDismissed(flowId: String, atStep: Int)

    // Async hooks (optional)
    suspend fun onBeforeStepAdvance(flowId: String, fromStepId: String, stepIndex: Int, stepType: String, responses: Map<String, Any>, stepData: Map<String, Any>?): StepAdvanceResult
    suspend fun onBeforeStepRender(flowId: String, stepId: String, stepIndex: Int, stepType: String, responses: Map<String, Any>): StepConfigOverride?
}

AppDNAPaywallDelegate

interface AppDNAPaywallDelegate {
    fun onPaywallPresented(paywallId: String)
    fun onPaywallAction(paywallId: String, action: PaywallAction)
    fun onPaywallPurchaseStarted(paywallId: String, productId: String)
    fun onPaywallPurchaseCompleted(paywallId: String, productId: String, transaction: TransactionInfo)
    fun onPaywallPurchaseFailed(paywallId: String, error: Throwable)
    fun onPaywallDismissed(paywallId: String)
    fun onPromoCodeSubmit(paywallId: String, code: String, completion: (Boolean) -> Unit)
    fun onPostPurchaseDeepLink(paywallId: String, url: String)
    fun onPostPurchaseNextStep(paywallId: String)
    fun onPaywallRestoreStarted(paywallId: String)
    fun onPaywallRestoreCompleted(paywallId: String, productIds: List<String>)
    fun onPaywallRestoreFailed(paywallId: String, error: Throwable)
}

AppDNAInAppMessageDelegate

interface AppDNAInAppMessageDelegate {
    fun onMessageShown(messageId: String, trigger: String)
    fun onMessageAction(messageId: String, action: String, data: Map<String, Any>?)
    fun onMessageDismissed(messageId: String)
    fun shouldShowMessage(messageId: String): Boolean
}

AppDNASurveyDelegate

interface AppDNASurveyDelegate {
    fun onSurveyPresented(surveyId: String)
    fun onSurveyCompleted(surveyId: String, responses: List<SurveyResponse>)
    fun onSurveyDismissed(surveyId: String)
}

AppDNADeepLinkDelegate

interface AppDNADeepLinkDelegate {
    fun onDeepLinkReceived(url: String, params: Map<String, String>)
}

Types

AppDNAOptions

data class AppDNAOptions(
    val flushInterval: Long = 30L,
    val batchSize: Int = 20,
    val configTTL: Long = 3600L,
    val logLevel: LogLevel = LogLevel.WARNING,
    val notificationIcon: Int = 0,
)

Environment

enum class Environment(val baseUrl: String) {
    PRODUCTION("https://api.appdna.ai"),
    SANDBOX("https://api.appdna.ai") // same URL — sandbox routed via `adn_test_` key prefix
}

LogLevel

enum class LogLevel(val value: Int) {
    NONE(0),
    ERROR(1),
    WARNING(2),
    INFO(3),
    DEBUG(4)
}

PaywallContext

data class PaywallContext(
    val placement: String,
    val experiment: String? = null,
    val variant: String? = null
)

OnboardingContext

data class OnboardingContext(
    val source: String? = null,
    val campaign: String? = null,
    val referrer: String? = null,
    val userProperties: Map<String, Any>? = null,
    val experimentOverrides: Map<String, String>? = null
)

PushPayload

data class PushPayload(
    val pushId: String,
    val title: String,
    val body: String,
    val imageUrl: String? = null,
    val data: Map<String, Any>? = null,
    val action: PushAction? = null
)

PushAction

data class PushAction(
    val type: String,
    val value: String
)

TransactionInfo

data class TransactionInfo(
    val transactionId: String,
    val productId: String,
    val purchaseDate: String,
    val environment: String
)

Entitlement

data class Entitlement(
    val productId: String,
    val store: String,
    val status: String,
    val expiresAt: String? = null,
    val isTrial: Boolean,
    val offerType: String? = null
)

ProductInfo

data class ProductInfo(
    val id: String,
    val name: String,
    val description: String,
    val formattedPrice: String,
    val priceMicros: Long,
    val currencyCode: String,
    val offerToken: String? = null
)

PurchaseResult

sealed class PurchaseResult {
    data class Purchased(val entitlement: Entitlement) : PurchaseResult()
    object Cancelled : PurchaseResult()
    object Pending : PurchaseResult()
    object Unknown : PurchaseResult()
    data class Failed(val error: Exception) : PurchaseResult()
}

PaywallAction

enum class PaywallAction {
    CTA_TAPPED,
    FEATURE_SELECTED,
    PLAN_CHANGED,
    LINK_TAPPED,
    CUSTOM
}

DismissReason

enum class DismissReason {
    PURCHASED,
    RESTORE_SUCCESS,
    DISMISSED,
    TAPPED_OUTSIDE,
    PROGRAMMATIC,
}

WebEntitlement

data class WebEntitlement(
    val isActive: Boolean,
    val planName: String?,
    val priceId: String?,
    val interval: String?,
    val status: String,
    val currentPeriodEnd: Long?, // Unix seconds
    val trialEnd: Long?,         // Unix seconds
)
data class DeferredDeepLink(
    val screen: String,
    val params: Map<String, String>,
    val visitorId: String,
)

StepAdvanceResult

sealed class StepAdvanceResult {
    object Proceed : StepAdvanceResult()
    data class ProceedWithData(val data: Map<String, Any>) : StepAdvanceResult()
    data class Block(val message: String) : StepAdvanceResult()
    data class Stay(val message: String? = null) : StepAdvanceResult()
    data class SkipTo(val stepId: String, val data: Map<String, Any>? = null) : StepAdvanceResult()
}

StepConfigOverride

data class StepConfigOverride(
    val fieldDefaults: Map<String, Any>? = null,
    val title: String? = null,
    val subtitle: String? = null,
    val ctaText: String? = null,
    val layoutOverrides: Map<String, Any>? = null
)

FormFieldType

enum class FormFieldType {
    TEXT, TEXTAREA, NUMBER, EMAIL, PHONE,
    DATE, TIME, DATETIME,
    SELECT, SLIDER, TOGGLE, STEPPER, SEGMENTED,
    PASSWORD, RATING, RANGE_SLIDER, IMAGE_PICKER,
    COLOR, URL, MULTILINE_CHIPS, SIGNATURE, LOCATION,
}

LocationData

data class LocationData(
    val raw_query: String,
    val formatted_address: String,
    val city: String,
    val state: String,
    val state_code: String,
    val country: String,
    val country_code: String,
    val latitude: Double,
    val longitude: Double,
    val timezone: String,
    val timezone_offset: Int,
    val postal_code: String? = null,
)

Server-Driven Screens

MethodSignatureDescription
showScreenshowScreen(screenId: String, completion: ((ScreenResult) -> Unit)?)Present a server-driven screen by ID.
showFlowshowFlow(flowId: String, completion: ((FlowResult) -> Unit)?)Present a multi-screen flow by ID.
dismissScreendismissScreen()Dismiss the currently presented screen or flow.
enableNavigationInterceptionenableNavigationInterception(forScreens: List<String>?)Enable automatic screen injection between navigations. Pass null for all screens.
disableNavigationInterceptiondisableNavigationInterception()Disable navigation interception.
previewScreenpreviewScreen(json: String)Debug only. Preview a screen from raw JSON config.
screenDelegatevar screenDelegate: AppDNAScreenDelegate?Set a delegate for screen lifecycle callbacks.
isConsentGrantedisConsentGranted(): BooleanCheck if analytics consent has been granted.
getUserTraitsgetUserTraits(): Map<String, Any>Get the current user traits set via identify() (empty map if none set).

AppDNAScreenDelegate

The delegate uses untyped maps (rather than the typed ScreenResult / FlowResult data classes) so the SDK can add fields without breaking host implementations:
interface AppDNAScreenDelegate {
    fun onScreenPresented(screenId: String) {}
    fun onScreenDismissed(screenId: String, result: Map<String, Any?>) {}
    fun onFlowCompleted(flowId: String, result: Map<String, Any?>) {}
    fun onScreenAction(screenId: String, action: Map<String, Any?>): Boolean = true
}
Common result-map keys: screen_id, dismissed, responses, last_action, duration_ms, error. Flow keys: flow_id, completed, last_screen_id, responses, screens_viewed (List<String>), duration_ms, error.

ScreenResult

Delivered to the showScreen top-level callback (not the delegate):
data class ScreenResult(
    val screenId: String,
    val dismissed: Boolean,
    val responses: Map<String, Any>,
    val lastAction: String?,
    val durationMs: Long?,
    val error: String?,
)

FlowResult

Delivered to the showFlow top-level callback (not the delegate):
data class FlowResult(
    val flowId: String,
    val completed: Boolean,
    val lastScreenId: String?,
    val responses: Map<String, Any>,
    val screensViewed: List<String>,
    val durationMs: Long?,
    val error: String?,
)

Properties

PropertyTypeDescription
AppDNA.sdkVersionStringThe current SDK version string (e.g., "1.0.33").
AppDNA.currentBundleVersionIntThe current config bundle version number.
AppDNA.configUpdatedSharedFlow<Unit>Coroutine flow that emits when remote config is updated. Collect with lifecycleScope.launch { AppDNA.configUpdated.collect { ... } }.
AppDNA.pushDelegateAppDNAPushDelegate?Top-level proxy for the push delegate (mirror of AppDNA.push.setDelegate(...)).
AppDNA.billingDelegateAppDNABillingDelegate?Top-level proxy for the billing delegate.
AppDNA.screenDelegateAppDNAScreenDelegate?Delegate for server-driven screen lifecycle.