Edit in GitHubLog an issue

Fetch and Display Inbox

This tutorial explains how to fetch and display an Inbox in your application.

Pre-requisites

Integrate and register the AEPMessaging extension in your app.

Fetch Inbox Content

To fetch the inbox content for the surfaces configured in Adobe Journey Optimizer campaigns, call the updatePropositionsForSurfaces API. You should batch requests for multiple surfaces in a single API call when possible.

Copied to your clipboard
let inboxSurface = Surface(path: "inbox")
Messaging.updatePropositionsForSurfaces([inboxSurface])

Display Inbox

To display an Inbox, call getInboxUI with your configured surface. This API returns an InboxUI instance immediately, which manages its own state transitions — loading, loaded, and error — automatically.

SwiftUI Application

Use the InboxUI.view property to embed the Inbox directly into your SwiftUI view hierarchy.

Copied to your clipboard
import SwiftUI
import AEPMessaging
struct InboxPage: View {
let inboxUI: InboxUI
init() {
let inboxSurface = Surface(path: "inbox")
inboxUI = Messaging.getInboxUI(for: inboxSurface)
}
var body: some View {
NavigationView {
inboxUI.view
.navigationTitle("Inbox")
}
.onAppear {
let inboxSurface = Surface(path: "inbox")
Messaging.updatePropositionsForSurfaces([inboxSurface])
}
}
}

UIKit Application

To display an Inbox in UIKit, wrap the SwiftUI InboxUI.view using UIHostingController.

Copied to your clipboard
import UIKit
import SwiftUI
import AEPMessaging
class InboxViewController: UIViewController {
var inboxUI: InboxUI!
override func viewDidLoad() {
super.viewDidLoad()
title = "Inbox"
let inboxSurface = Surface(path: "inbox")
inboxUI = Messaging.getInboxUI(for: inboxSurface)
let hostingController = UIHostingController(rootView: inboxUI.view)
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
Messaging.updatePropositionsForSurfaces([inboxSurface])
}
}

Refreshing Inbox Data

The Inbox provides two ways to refresh content.

Pull-to-Refresh

Enable pull-to-refresh to let users refresh content by pulling down on the Inbox.

Copied to your clipboard
let inboxSurface = Surface(path: "inbox")
let inboxUI = Messaging.getInboxUI(for: inboxSurface)
inboxUI.isPullToRefreshEnabled = true

Programmatic Refresh

Call refresh() to programmatically trigger a content refresh.

Copied to your clipboard
inboxUI.refresh()

Best Practices

  1. Fetch Early: Call updatePropositionsForSurfaces when your app launches or when the user navigates to the Inbox screen to ensure fresh content is available.

  2. Surface Naming: Use descriptive surface paths that match your Adobe Journey Optimizer campaign configuration (e.g., Surface(path: "inbox"), Surface(path: "home_feed")).

  3. Reuse InboxUI: Keep the InboxUI instance alive as long as the Inbox view is visible. The InboxUI maintains state and efficiently updates when content changes.

  4. Handle Multiple Surfaces: If your app has multiple Inboxes, create separate InboxUI instances with different surfaces.

Copied to your clipboard
let notificationsInboxUI = Messaging.getInboxUI(for: Surface(path: "notifications"))
let promotionsInboxUI = Messaging.getInboxUI(for: Surface(path: "promotions"))

Next Steps

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2026 Adobe. All rights reserved.