Edit in GitHubLog an issue

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

Copied to your clipboard
@available(iOS 15.0, *)
public class InboxUI: Identifiable, ObservableObject

Public Properties

PropertyTypeDescription
id
UUID
A unique identifier for this inbox instance.
surface
Surface
The surface this inbox is bound to.
state
The current state of the inbox. Published — changes automatically update the view.
inboxSchemaData
The inbox schema data, including layout, heading, and empty state settings. Published and read-only.
listener
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(surface:customizer:listener:)

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

Parameters

  • surface - The Surface for which to display the inbox.
  • customizer - An optional ContentCardCustomizing object to customize the appearance of content cards within the inbox.
  • listener - An optional InboxEventListening object to listen to inbox events.

Syntax

Copied to your clipboard
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

Copied to your clipboard
public func refresh()

Example

Copied to your clipboard
inboxUI.refresh()

setBackground(_:)

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

Parameters

  • view - A SwiftUI View to use as the inbox background.

Syntax

Copied to your clipboard
public func setBackground<V: View>(_ view: V)

Example

Copied to your clipboard
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

  • builder - A closure that returns an AnyView to display while the inbox is loading.

Syntax

Copied to your clipboard
public func setLoadingView(_ builder: @escaping () -> AnyView)

Example

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

setErrorView(_:)

Replaces the default error view with a custom view.

Parameters

  • builder - A closure that receives the Error and returns an AnyView to display when the inbox fails to load.

Syntax

Copied to your clipboard
public func setErrorView(_ builder: @escaping (Error) -> AnyView)

Example

Copied to your clipboard
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

  • builder - A closure that receives the optional EmptyStateSettings and returns an AnyView to display when the inbox has no content.

Syntax

Copied to your clipboard
public func setEmptyView(_ builder: @escaping (EmptyStateSettings?) -> AnyView)

Example

Copied to your clipboard
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

  • builder - A closure that receives the AEPText heading configured in Adobe Journey Optimizer and returns an AnyView.

Syntax

Copied to your clipboard
public func setHeadingView(_ builder: @escaping (AEPText) -> AnyView)

Example

Copied to your clipboard
inboxUI.setHeadingView { heading in
AnyView(
HStack {
Image(systemName: "tray.fill")
heading.view
.font(.title2)
.fontWeight(.bold)
}
.padding()
)
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2026 Adobe. All rights reserved.