API Reference

This document lists the public APIs available in the Messaging extension for implementing Inbox UI with qualified content cards.

Importing Messaging

To use the Messaging APIs, import the Messaging module in your Swift file.

data-slots=heading, code
data-repeat=1
data-languages=Swift

Swift

import AEPMessaging

getInboxUI

The getInboxUI method obtains an InboxUI instance for a given surface so you can display a SwiftUI Inbox view with the qualified content cards.

Parameters

data-variant=info
data-slots=text
This API returns an InboxUI immediately. The inbox will not have content until proposition data has been fetched for the same surface. You must call the updatePropositionsForSurfaces API with the desired surfaces prior to or after obtaining the inbox UI, depending on when you want content to appear.

Syntax

data-slots=heading, code
data-repeat=1
data-languages=Swift

Swift

@available(iOS 15.0, *)
public static func getInboxUI(for surface: Surface,
                              customizer: ContentCardCustomizing? = nil,
                              listener: InboxEventListening? = nil) -> InboxUI

Example

data-slots=heading, code
data-repeat=1
data-languages=Swift

Swift

// Create a surface matching your Adobe Journey Optimizer campaign configuration
let inboxSurface = Surface(path: "inbox")

// Get the InboxUI instance
let inboxUI = Messaging.getInboxUI(for: inboxSurface)

// Display the inbox view in SwiftUI
struct InboxPage: View {
    var body: some View {
        inboxUI.view
            .onAppear {
                Messaging.updatePropositionsForSurfaces([inboxSurface])
            }
    }
}

Example with listener and customizer

data-slots=heading, code
data-repeat=1
data-languages=Swift

Swift

let inboxSurface = Surface(path: "inbox")

let inboxUI = Messaging.getInboxUI(
    for: inboxSurface,
    customizer: MyCardCustomizer(),
    listener: self
)

Typical Usage Flow

  1. Register and configure the AEPMessaging extension at app launch.
  2. Call updatePropositionsForSurfaces to download inbox content.
  3. Call Messaging.getInboxUI(for:) to obtain an InboxUI instance.
  4. Display the inbox using the InboxUI.view property in your SwiftUI or UIKit view.
  5. Optionally assign a listener and customizer to respond to events and style the inbox.
data-slots=heading, code
data-repeat=1
data-languages=Swift

Swift

import SwiftUI
import AEPMessaging

struct InboxPage: View {
    let inboxUI: InboxUI

    init() {
        let surface = Surface(path: "inbox")
        inboxUI = Messaging.getInboxUI(for: surface)
        inboxUI.isPullToRefreshEnabled = true
    }

    var body: some View {
        NavigationView {
            inboxUI.view
                .navigationTitle("Inbox")
        }
        .onAppear {
            Messaging.updatePropositionsForSurfaces([Surface(path: "inbox")])
        }
    }
}

Next Steps