Skip to main content
In-app messages appear while users are active in your app. The iOS SDK displays them automatically when you enable the in-app module and identify the user.

Enable in-app messaging

  1. Install the ZixflowMessagingInApp pod or the MessagingInApp SPM product (see Installation).
  2. Initialize the module after core SDK init:
import ZixflowDataPipelines
import ZixflowMessagingInApp

let config = SDKConfigBuilder(apiKey: "YOUR_API_KEY").build()
Zixflow.initialize(withConfig: config)

MessagingInApp.initialize(
    withConfig: MessagingInAppConfigBuilder().build()
)
Note: MessagingInAppConfigBuilder currently has no additional customer-facing options. Call .build() after creating the builder.

Identify users

Identify a user before personalized in-app messages can be delivered:
Zixflow.shared.identify(
    userId: "user-123",
    traits: [
        "email": "user@example.com"
    ]
)

How messages appear

  1. Create and launch an in-app campaign in the Zixflow dashboard.
  2. When campaign conditions match, the SDK fetches and displays the message.
  3. No extra UI code is required for standard modal messages—the SDK renders them.
Track screen views if your campaigns target specific screens:
Zixflow.shared.screen(title: "Home")
You can also enable .autoTrackUIKitScreenViews() or use .screenViewUse(screenView: .inApp) so screen events drive in-app page rules (see Advanced Configuration).

Listen for in-app events

Conform to InAppEventListener and register it on the shared instance:
import ZixflowMessagingInApp

class AppDelegate: UIResponder, UIApplicationDelegate, InAppEventListener {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        // ... Zixflow.initialize ...

        MessagingInApp
            .initialize(withConfig: MessagingInAppConfigBuilder().build())
            .setEventListener(self)

        return true
    }

    func messageShown(message: InAppMessage) {
        print("Shown \(message.messageId)")
    }

    func messageDismissed(message: InAppMessage) {
        print("Dismissed \(message.messageId)")
    }

    func errorWithMessage(message: InAppMessage) {
        print("Error \(message.messageId)")
    }

    func messageActionTaken(
        message: InAppMessage,
        actionValue: String,
        actionName: String
    ) {
        print("Action \(actionName) \(actionValue)")
    }
}
CallbackWhen it fires
messageShownMessage is displayed
messageDismissedMessage is closed
messageActionTakenUser taps a message action
errorWithMessageMessage fails to display

Dismiss a message

MessagingInApp.shared.dismissMessage()

Inline in-app messages

Use an inline view whose elementId matches the placement ID in your campaign.

SwiftUI

import SwiftUI
import ZixflowMessagingInApp

struct PromoBanner: View {
    var body: some View {
        InlineMessage(elementId: "home-banner") { message, actionValue, actionName in
            print("Inline action: \(actionName) \(actionValue)")
        }
    }
}

UIKit

import ZixflowMessagingInApp

let banner = InlineMessageUIView(elementId: "home-banner")
view.addSubview(banner)
// Add your own Auto Layout constraints (the view manages its height)

Notification inbox

Access persistent inbox messages via MessagingInApp.shared.inbox:
import ZixflowMessagingInApp

let inbox = MessagingInApp.shared.inbox

// One-shot fetch
Task {
    let messages = await inbox.getMessages()
    // Optionally: await inbox.getMessages(topic: "promotions")
}

// Live updates (AsyncStream)
Task {
    for await messages in inbox.messages() {
        // Rebuild your inbox UI
    }
}

// Mark read / unread / delete / track clicks
inbox.markMessageOpened(message: message)
inbox.markMessageUnopened(message: message)
inbox.markMessageDeleted(message: message)
inbox.trackMessageClicked(message: message, actionName: "cta")
You can also use addChangeListener / removeChangeListener on the main actor if you prefer a listener-based API. For the full method list, see the API Reference.