Package 

Object AppDNA


  • 
    public class AppDNA
    
                        

    Main entry point for the AppDNA Android SDK. All public methods are thread-safe.

    • Method Detail

      • registerCustomView

         final static Unit registerCustomView(String key, Function1<Map<String, Object>, Unit> factory)

        Register a custom Composable factory for use in onboarding content blocks.

        Parameters:
        key - The view_key value from the block config.
        factory - A composable factory that receives the block's custom config map.
      • getApplicationContext

         final static Context getApplicationContext()

        Internal accessor used by manager classes (e.g. ScreenManager) that need to launch host Activities from outside an Activity context. Returns null when the SDK has not yet been configured.

        SPEC-070-A finalization Lens B P0 — required by ScreenHostActivity launch path so AppDNA.showScreen(id) can present a real Activity even when the caller didn't supply one (matches iOS where AppDNA.showScreen reads the application's key window itself).

      • reset

         final static Unit reset()

        Clear user identity (keeps anonymous ID).

        Resets the host-supplied user identity, experiment exposures, the in-app message session, the survey session, the web-entitlement observer, and the journey-triggered pending-message listener. Does NOT clear the device's first-identifier anchor used by the cross-account-entitlement-leak defence (see EntitlementOwnerFilter) — that anchor is intentionally durable for the lifetime of the app installation. App uninstall, or Settings → Apps → Clear data, is the only path that wipes it. This makes reset() safe to call as the host's "sign-out" hook without re-opening the leak surface for a subsequent user signing in on the same device.

      • notifyScreenAppeared

         final Unit notifyScreenAppeared(String screenName)

        SPEC-070-A A.10: notify the SDK that a Compose-only screen has appeared (Activity-based screens fire automatically via the lifecycle callback registered in configure()). Hosts should call this from LaunchedEffect(Unit) of any composable that represents a navigable destination if they want it to participate in NavigationInterceptor hooks.

      • flush

         final static Unit flush()

        Force flush all queued events immediately.

      • forceRefreshConfig

         final static Unit forceRefreshConfig()

        SPEC-067: Force an immediate config refresh, bypassing the cache TTL.

      • getExperimentVariant

         final static String getExperimentVariant(String experimentId)

        Get the variant assignment for an experiment. Exposure is auto-tracked on first call per session.

      • presentPaywall

        @JvmOverloads() final static Unit presentPaywall(Activity activity, String id, PaywallContext context, AppDNAPaywallDelegate listener)

        Present a paywall by ID from the given Activity. Fetches the paywall config from remote config and presents the paywall UI.

        Parameters:
        activity - The Activity to present from.
        id - The paywall ID (matching Firestore config).
        context - Optional paywall context (placement, experiment, variant).
        listener - Optional listener for paywall lifecycle events.
      • presentPaywall

        @JvmOverloads() final static Unit presentPaywall(Activity activity, String id, PaywallContext context)

        Present a paywall by ID from the given Activity. Fetches the paywall config from remote config and presents the paywall UI.

        Parameters:
        activity - The Activity to present from.
        id - The paywall ID (matching Firestore config).
        context - Optional paywall context (placement, experiment, variant).
      • presentPaywall

        @JvmOverloads() final static Unit presentPaywall(Activity activity, String id)

        Present a paywall by ID from the given Activity. Fetches the paywall config from remote config and presents the paywall UI.

        Parameters:
        activity - The Activity to present from.
        id - The paywall ID (matching Firestore config).
      • presentPaywallByPlacement

        @JvmOverloads() final static Unit presentPaywallByPlacement(Activity activity, String placement, PaywallContext context, AppDNAPaywallDelegate listener)

        SPEC-070-A finalization B6#P0-24 — facade overload for placement-based paywall presentation. Mirrors iOS AppDNA.presentPaywall(placement:from:context:delegate:) which selects the best paywall by audience rules + priority. The underlying selection algorithm lives in ai.appdna.sdk.paywalls.PaywallManager.presentByPlacement — this is a thin wrapper so hosts don't have to reach through AppDNA.paywalls.manager?.presentByPlacement(...).

      • presentPaywallByPlacement

        @JvmOverloads() final static Unit presentPaywallByPlacement(Activity activity, String placement, PaywallContext context)

        SPEC-070-A finalization B6#P0-24 — facade overload for placement-based paywall presentation. Mirrors iOS AppDNA.presentPaywall(placement:from:context:delegate:) which selects the best paywall by audience rules + priority. The underlying selection algorithm lives in ai.appdna.sdk.paywalls.PaywallManager.presentByPlacement — this is a thin wrapper so hosts don't have to reach through AppDNA.paywalls.manager?.presentByPlacement(...).

      • presentPaywallByPlacement

        @JvmOverloads() final static Unit presentPaywallByPlacement(Activity activity, String placement)

        SPEC-070-A finalization B6#P0-24 — facade overload for placement-based paywall presentation. Mirrors iOS AppDNA.presentPaywall(placement:from:context:delegate:) which selects the best paywall by audience rules + priority. The underlying selection algorithm lives in ai.appdna.sdk.paywalls.PaywallManager.presentByPlacement — this is a thin wrapper so hosts don't have to reach through AppDNA.paywalls.manager?.presentByPlacement(...).

      • presentOnboarding

        @JvmOverloads() final static Boolean presentOnboarding(Activity activity, String flowId, AppDNAOnboardingDelegate listener)

        Present an onboarding flow by ID. Returns false if config is unavailable. If flowId is null, the active flow from remote config is used.

        Parameters:
        activity - The Activity to present from.
        flowId - Optional flow ID.
        listener - Optional listener for onboarding lifecycle events.
      • presentOnboarding

        @JvmOverloads() final static Boolean presentOnboarding(Activity activity, String flowId)

        Present an onboarding flow by ID. Returns false if config is unavailable. If flowId is null, the active flow from remote config is used.

        Parameters:
        activity - The Activity to present from.
        flowId - Optional flow ID.
      • presentOnboarding

        @JvmOverloads() final static Boolean presentOnboarding(Activity activity)

        Present an onboarding flow by ID. Returns false if config is unavailable. If flowId is null, the active flow from remote config is used.

        Parameters:
        activity - The Activity to present from.
      • previewScreen

         final Boolean previewScreen(String json)

        SPEC-070-A I.11 — preview a server-driven screen from a raw JSON payload (no remote-config fetch). Mirrors iOS AppDNA.previewScreen(json:). Used by the console live-preview pipe + integration tests. Returns true if the JSON parsed and a screen was presented, false otherwise.

      • getLocationData

         final LocationData getLocationData(String fieldId)

        SPEC-070-A I.11 — fetch the structured ai.appdna.sdk.onboarding.LocationData captured by the named onboarding form field. Returns null if the field hasn't been answered yet, was answered with a free-text value, or no flow has run this session. Mirrors iOS AppDNA.getLocationData(fieldId:).

      • registerBackgroundTasks

         final Unit registerBackgroundTasks()

        SPEC-070-A I.11 — schedule (or re-schedule) all SDK-owned background tasks. Hosts can call this to opt into the periodic config refresh job before configure returns, or after the host's WorkManager has finished initialising. Idempotent — WorkManager dedupes by unique-name. Mirrors iOS AppDNA.registerBackgroundTasks().

      • diagnose

         final String diagnose()

        SPEC-070-A I.11 — debug snapshot of the SDK's bootstrap state. Returns a multi-line human-readable string covering: configured flag, env (production / sandbox), api base url, identity (anon_id + user_id), org/app ids, sdk version, current bundle version, consent status. Mirrors iOS AppDNA.diagnose(). Safe to call before configure() — unset fields surface as <unset>.

      • showFlow

        @JvmOverloads() final static Unit showFlow(String flowId, Function1<FlowResult, Unit> callback)

        Show a server-driven multi-screen flow by ID. Mirrors iOS AppDNA.showFlow(_:completion:) at AppDNA.swift:406. Forwards to ScreenManager.shared.showFlow(...). R87 P2 — surfaced as @JvmStatic + @JvmOverloads so Java callers can call AppDNA.showFlow("welcome") without supplying a null callback.

      • showFlow

        @JvmOverloads() final static Unit showFlow(String flowId)

        Show a server-driven multi-screen flow by ID. Mirrors iOS AppDNA.showFlow(_:completion:) at AppDNA.swift:406. Forwards to ScreenManager.shared.showFlow(...). R87 P2 — surfaced as @JvmStatic + @JvmOverloads so Java callers can call AppDNA.showFlow("welcome") without supplying a null callback.

      • dismissScreen

         final static Unit dismissScreen()

        Dismiss the currently presented server-driven screen or flow.

      • showPaywall

         final static Unit showPaywall(String id)

        Shorthand to show a paywall by ID (used by SDUI screen action routing).

        Resolves the most-recently-resumed Activity (tracked by NavigationInterceptorActivityCallbacks) and routes through presentPaywall. Mirrors iOS AppDNA.showPaywall(_:) which presents from the top-most view controller.

      • showSurvey

         final static Unit showSurvey(String id)

        Shorthand to show a survey by ID (used by screen action routing).

      • setPushToken

         final static Unit setPushToken(String token)

        Set the FCM push token. Call from FirebaseMessagingService.onNewToken(). This registers the token with the backend for direct push delivery.

      • trackPushDelivered

         final Unit trackPushDelivered(String pushId)

        Track that a push notification was delivered. Call from FirebaseMessagingService.onMessageReceived().

      • handlePushTap

         final static Boolean handlePushTap(Intent intent)

        SPEC-070-A H.5 + H.9 — single entry point hosts call from Activity.onCreate(savedInstanceState) / onNewIntent(intent) to:

        • Track push_tapped (carries push_id + action_id),

        • Fire AppDNAPushDelegate.onPushTapped with a typed PushPayload,

        • Auto-route built-in actions (screen_id, deep_link, action_type=show_screen, etc.) without requiring host code.

        Safe to call with any intent — does nothing if push_id extra is absent (so hosts can call unconditionally).

      • onNewPushToken

         final static Unit onNewPushToken(String token)

        Called when FCM token refreshes. Re-registers with backend.

        SPEC-070-A finalization Lens D P0: when called BEFORE configure, buffer the token in pendingPushTokenBeforeConfigure and replay it inside configure() once pushTokenManager is wired. Without this, apps that registered FCM at boot dropped tokens silently.

      • setSessionData

         final static Unit setSessionData(String key, Object value)

        Store a key-value pair in the cross-module session data store. Available to all modules via {{session.key}} template variables.

      • setConsent

         final Unit setConsent(Boolean analytics)

        Set analytics consent. When false, events are silently dropped.

      • setLogLevel

         final static Unit setLogLevel(String level)

        Set the SDK log level at runtime. Valid values: "none", "error", "warning", "info", "debug".

      • setLogLevel

         final static Unit setLogLevel(LogLevel level)

        SPEC-070-A finalization Phase C — strict-typed LogLevel overload. Mirrors iOS setLogLevel(_ level: LogLevel) (typed enum, no stringly-typed fallback). Java callers can use either overload (AppDNA.setLogLevel("debug") or AppDNA.setLogLevel(LogLevel.DEBUG)).

      • onReady

         final Unit onReady(Function0<Unit> callback)

        Register a callback that fires when the SDK is fully initialized.

      • shutdown

         final Unit shutdown()

        Shut down the SDK and release resources. Call from Application.onTerminate().

        SPEC-070-A H.24 — release ALL native handles + cancel ALL coroutine scopes. Previous implementation cancelled scope but leaked nativeBillingManager's BillingClient connection, the event SQLite handle, the survey/messages/push manager scopes, and the periodic config-refresh worker.

      • getConfigUpdated

         final static SharedFlow<Unit> getConfigUpdated()

        Hot Flow that emits Unit on every successful remote-config refresh.

      • getRegisteredCustomViews

         final static Map<String, Function1<Map<String, Object>, Unit>> getRegisteredCustomViews()

        Registry of developer-provided Composable factories keyed by view_key. Used by the custom_view content block to render developer escape-hatch views.