Implement Inbox Messaging on iOS

The SDK provides convenience methods for refreshing the inbox and managing messages, including retrieving, reading, and deleting them. Enable inbox messaging during SDK initialization to access message properties, manage Alert + Inbox notifications, and customize message handling for your app users.

The SDK supports three types of inbox messages:

  • Inbox 1.0 - The original inbox message format with CloudPage URLs
  • Inbox 2.0 - Enhanced inbox messages with additional fields like subtitles and messages, plus new call-to-action options including App URL, Web URL, and None (introduced in SDK version 9.0)
  • Push Copy to Inbox (PCTI) - Push notifications that also appear in the inbox

To enable these inbox features during SDK initialization, use the setInboxEnabled method of the MarketingCloudSdkConfigBuilder class.

For SDK versions 8 and earlier, show Inbox Only messages sent from Marketing Cloud Engagement in your app by using the UITableView data source provided by the SDK in a UIViewController. The UIViewController serves as the inbox in your app to show these messages. The SDK automatically updates the UITableView data source with new messages after they’re downloaded.

Manage row selection in your table view using the SDK’s basic UITableView delegate. If your app requires custom behavior, implement your own UITableView delegate.

This example demonstrates a basic inbox implementation using the SDK as the data source and delegate.

Use this code to implement a basic inbox in version 8 of the SDK for iOS.

1var dataSource: InboxMessagesDataSource?
2var delegate: InboxMessagesDelegate?
3
4override func viewDidLoad() {
5    super.viewDidLoad()
6
7    dataSource = SFMCSdk.mp.inboxMessagesTableViewDataSourceFor(tableView: self.tableView)
8    delegate = SFMCSdk.mp.inboxMessagesTableViewDelegateFor(tableView: self.tableView, dataSource: dataSource!)
9
10    self.tableView.dataSource = dataSource
11    self.tableView.delegate = delegate
12    ...
13}

Use this code to implement a basic inbox in version 7 of the SDK for iOS.

1var dataSource: MarketingCloudSDKInboxMessagesDataSource?
2var delegate: MarketingCloudSDKInboxMessagesDelegate?
3
4override func viewDidLoad() {
5    super.viewDidLoad()
6
7    dataSource = MarketingCloudSDK.sharedInstance().sfmc_inboxMessagesTableViewDataSource(for: self.tableView)
8    delegate = MarketingCloudSDK.sharedInstance().sfmc_inboxMessagesTableViewDelegate(for: self.tableView, dataSource: dataSource!)
9
10    self.tableView.dataSource = dataSource
11    self.tableView.delegate = delegate
12    ...
13}

For greater control over the presentation and user experience of your inbox, implement your own data source and delegate using the methods provided by the SDK.

With Inbox 2.0 in SDK version 9 and later, the SDK no longer supports custom data sources and delegates for the inbox table view. These methods have been removed:

  • inboxMessagesTableViewDataSourceFor(tableView:)
  • inboxMessagesTableViewDelegateFor(tableView:dataSource:)

In SDK version 9 or later, use the SDK’s convenience methods to retrieve and manage inbox messages directly. See Public Properties for available methods.

For more information about inbox message management methods, see the InboxMessages Method Reference.

Public Properties 

Access inbox message properties using convenience methods that retrieve all messages, unread messages, read messages, or deleted messages. Each message dictionary contains properties like ID, subject, dates, custom data, and message type that your app can use.

Alert + Inbox Messages 

Configure Alert + Inbox messages to enable users to tap on an inbox push notification and get redirected to the corresponding inbox message. Configure automatic read marking when notifications are tapped, and refresh inbox messages when your app is in the foreground.