InboxUI

InboxUI is the main class for displaying an Inbox in your application. It manages its own state transitions — loading, loaded, and error — and provides a SwiftUI view that renders content cards using the layout and settings configured in Adobe Journey Optimizer.

Class Definition

@available(iOS 15.0, *)
public class InboxUI: Identifiable, ObservableObject

Public Properties

Property
Type
Description
id
UUID
A unique identifier for this inbox instance.
surface
Surface
The surface this inbox is bound to.
state
InboxState
The current state of the inbox. Published — changes automatically update the view.
inboxSchemaData
InboxSchemaData?
The inbox schema data, including layout, heading, and empty state settings. Published and read-only.
listener
InboxEventListening?
An optional listener to receive inbox state and card interaction events.
isPullToRefreshEnabled
Bool
Whether pull-to-refresh is enabled. Default: false.
cardSpacing
CGFloat
The vertical spacing between content cards. Default: 16.
contentPadding
EdgeInsets
The padding around the content area. Default: EdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16).
unreadIconSize
CGFloat
The size of the unread indicator icon in points. Default: 16.
view
some View
The SwiftUI view representing the inbox. Use this to embed the inbox in your app's view hierarchy.

Initializer

init(surfacelistener:)

Creates a new InboxUI instance. Use Messaging.getInboxUI(for:) as the preferred way to create an InboxUI from a surface.

Parameters

Syntax

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

Swift

public init(surface: Surface,
            customizer: ContentCardCustomizing? = nil,
            listener: InboxEventListening? = nil)

Public Methods

refresh()

Programmatically triggers a refresh of inbox content. Calls updatePropositionsForSurfaces followed by getPropositionsForSurfaces for the inbox surface.

Syntax

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

Swift

public func refresh()

Example

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

Swift

inboxUI.refresh()

setBackground(_:)

Sets a custom background for the inbox container. Accepts any SwiftUI View — a color, gradient, image, etc.

Parameters

Syntax

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

Swift

public func setBackground<V: View>(_ view: V)

Example

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

Swift

inboxUI.setBackground(Color(.systemGroupedBackground))

inboxUI.setBackground(
    LinearGradient(colors: [.blue.opacity(0.1), .purple.opacity(0.05)],
                   startPoint: .top, endPoint: .bottom)
)

setLoadingView(_:)

Replaces the default loading view with a custom view.

Parameters

Syntax

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

Swift

public func setLoadingView(_ builder: @escaping () -> AnyView)

Example

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

Swift

inboxUI.setLoadingView {
    AnyView(
        VStack {
            ProgressView()
            Text("Loading your inbox...")
        }
    )
}

setErrorView(_:)

Replaces the default error view with a custom view.

Parameters

Syntax

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

Swift

public func setErrorView(_ builder: @escaping (Error) -> AnyView)

Example

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

Swift

inboxUI.setErrorView { error in
    AnyView(
        VStack {
            Text("Something went wrong")
            Text(error.localizedDescription)
                .foregroundColor(.secondary)
            Button("Try Again") { inboxUI.refresh() }
        }
    )
}

setEmptyView(_:)

Replaces the default empty state view with a custom view.

Parameters

Syntax

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

Swift

public func setEmptyView(_ builder: @escaping (EmptyStateSettings?) -> AnyView)

Example

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

Swift

inboxUI.setEmptyView { emptyStateSettings in
    AnyView(
        VStack {
            if let message = emptyStateSettings?.message {
                message.view
            } else {
                Text("No messages")
            }
        }
    )
}

setHeadingView(_:)

Replaces the default heading view with a custom view.

Parameters

Syntax

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

Swift

public func setHeadingView(_ builder: @escaping (AEPText) -> AnyView)

Example

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

Swift

inboxUI.setHeadingView { heading in
    AnyView(
        HStack {
            Image(systemName: "tray.fill")
            heading.view
                .font(.title2)
                .fontWeight(.bold)
        }
        .padding()
    )
}