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
- 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.
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
- 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.
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
- 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