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.
Swift
Copied to your clipboardimport 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:
- surface - The Surface for which to retrieve the inbox.
- customizer - An optional ContentCardCustomizing object to customize the appearance of the content cards within the inbox. If you do not need to customize the appearance of the content cards, this parameter can be omitted.
- listener - An optional InboxEventListening object to listen to state and interaction events from the inbox. If you do not need to listen to events, this parameter can be omitted.
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
Swift
Copied to your clipboard@available(iOS 15.0, *)public static func getInboxUI(for surface: Surface,customizer: ContentCardCustomizing? = nil,listener: InboxEventListening? = nil) -> InboxUI
Example
Swift
Copied to your clipboard// Create a surface matching your Adobe Journey Optimizer campaign configurationlet inboxSurface = Surface(path: "inbox")// Get the InboxUI instancelet inboxUI = Messaging.getInboxUI(for: inboxSurface)// Display the inbox view in SwiftUIstruct InboxPage: View {var body: some View {inboxUI.view.onAppear {Messaging.updatePropositionsForSurfaces([inboxSurface])}}}
Example with listener and customizer
Swift
Copied to your clipboardlet inboxSurface = Surface(path: "inbox")let inboxUI = Messaging.getInboxUI(for: inboxSurface,customizer: MyCardCustomizer(),listener: self)
Typical Usage Flow
- Register and configure the AEPMessaging extension at app launch.
- Call
updatePropositionsForSurfacesto download inbox content. - Call
Messaging.getInboxUI(for:)to obtain anInboxUIinstance. - Display the inbox using the
InboxUI.viewproperty in your SwiftUI or UIKit view. - Optionally assign a listener and customizer to respond to events and style the inbox.
Swift
Copied to your clipboardimport SwiftUIimport AEPMessagingstruct InboxPage: View {let inboxUI: InboxUIinit() {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
- Displaying Inbox - Detailed guide on displaying an Inbox in SwiftUI and UIKit
- Listening to Inbox Events - Respond to inbox state changes and card interactions
- Customizing Your Inbox - Customize appearance, spacing, and views
