Package 

Class MessageManager


  • 
    public final class MessageManager
    
                        

    SPEC-070-A A.9 — Manages in-app message trigger evaluation, frequency tracking, and presentation. Mirrors iOS InAppMessaging/MessageManager.swift:6-267.

    Architectural split (do not change):

    • MessageManager owns: trigger evaluation, condition matching, frequency tracking, candidate selection, queue gate, delegate veto, in_app_message_* analytics events, CTA action routing.

    • InAppMessageView (composable in InAppMessageRenderer.kt) owns: actual rendering of banner/modal/fullscreen/tooltip variants.

    MessageManager hosts the InAppMessageView inside a ComponentDialog — same approach PendingMessageListener uses — so journey-delivered and trigger-delivered messages both land in the same renderer.

    NOTE: this class deliberately does NOT touch the renderer ctor — it uses the existing @Composable InAppMessageView function directly. The renderer constructor parameter (kept on the public API for symmetry with iOS DI) is currently unused as a delivery handle; it only exists so a sample app or test can subclass / replace the presentation pipeline.

    • Method Detail

      • getDelegate

         final AppDNAInAppMessageDelegate getDelegate()

        Public delegate. Hosted by AppDNA.inAppMessages namespace — AppDNAModules.kt InAppMessagesModule.setDelegate(...) writes through to this field.

      • setDelegate

         final Unit setDelegate(AppDNAInAppMessageDelegate delegate)

        Public delegate. Hosted by AppDNA.inAppMessages namespace — AppDNAModules.kt InAppMessagesModule.setDelegate(...) writes through to this field.

      • onEvent

         final Unit onEvent(String eventName, Map<String, Object> props)

        Evaluate every active message against an event. Called from AppDNA.trackInternal() after the event has been written to the queue (see file-top wiring TODO).

      • resetSession

         final Unit resetSession()

        Clear in-session frequency counters. Called from AppDNA.reset().

        SPEC-401-A R86 (Lens B F1) — do NOT reset isPresenting here. iOS MessageManager.resetSession() leaves the gate untouched (InAppMessaging/MessageManager.swift:99-101). If AppDNA.reset() is called while a Dialog is actively showing, dropping the gate races a second concurrent present() (in-flight Dialog stays visible while a follow-up tracked event passes the gate and calls present() again, stacking dialogs). The gate is reset on natural dismiss or shutdown.

      • shutdown

         final Unit shutdown()

        SPEC-070-A final audit pass C F2 — release delay_seconds-queued runnables on SDK shutdown so Dialog presentations don't fire on a stale Activity reference after AppDNA.shutdown(). Mirrors the (ARC-driven) iOS DispatchWorkItem cancellation in InAppMessaging.