Implement Inbox Messaging on Android
Implement Inbox Messaging on iOS
Event Tracking
Push Messages in the Marketing Cloud Engagement REST API Reference
Transactional Push Messages in the Marketing Cloud Engagement REST API Reference
The MobilePush iOS SDK provides convenience methods for refreshing the inbox and managing messages, including retrieving, reading, and deleting them. For more information on these methods, see the InboxMessages Method Reference.
To enable Inbox 1.0, Inbox 2.0, and Push Copy to Inbox (PCTI) features during SDK initialization, use the setInboxEnabled method of the MarketingCloudSdkConfigBuilder class.
To show Inbox Only messages sent from Marketing Cloud Engagement in your app using SDK versions before 9.x, use 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.
You can manage row selection in your table view using the SDK’s basic UITableView delegate. If your app requires custom behavior, you can implement your own UITableView delegate.
This example demonstrates a basic inbox implementation using the SDK as the data source and delegate.
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}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, you can implement your own data source and delegate using the methods provided by the SDK.
With Inbox 2.0, the SDK no longer supports custom data sources and delegates for the inbox table view. Consequently, these methods have been removed in SDK version 9.x:
1public func inboxMessagesTableViewDataSourceFor(tableView: UITableView) -> InboxMessagesDataSource?
2public func inboxMessagesTableViewDelegateFor(tableView: UITableView, dataSource: InboxMessagesDataSource) -> InboxMessagesDelegate?The MobilePush SDK offers these convenience methods for retrieving inbox messages:
Each method returns an array of dictionaries (for example, [[String: AnyObject]]), where each dictionary represents a message. A consuming application can access these properties within each message dictionary.
| Key | Value | SDK Versions 8.x and 9.x Availability |
|---|---|---|
id | String? | Yes |
alert | String? | Yes |
subject | String? | Yes |
startDateUtc | Date? | Yes |
endDateUtc | Date? | Yes |
custom | String? | Yes |
name | String? | Yes |
title | String? | Yes |
url | String? | Yes |
deleted | Boolean | Yes |
read | Boolean | Yes |
sound | String? | Yes |
subtitle | String? | Yes |
inboxMessageType | Int? | Available in version 9.x and later |
inboxSubtitle | String? | Available in version 9.x and later |
inboxMessage | String? | Available in version 9.x and later |
notificationMessage | [String: Any]? | Available in version 9.x and later |
The inboxMessageType classifies inbox messages using integer values to represent different types. A value of 1 indicates an Inbox 1.0 message, 2 signifies an Inbox 2.0 message, and 3 represents a PCTI message. This attribute applies to Inbox 1.0, Inbox 2.0, and PCTI. Additionally, inboxSubtitle and inboxMessage are available to Inbox 2.0, while notificationMessage is specific to PCTI.
Note
The remaining properties in the message dictionary (such as, contentType, messageDeleted, messageHash, requestId, statusDirty) are for internal SDK use. Avoid using these properties within a consuming application as they’re subject to change.
The Alert + Inbox feature is designed to enable users to tap on an inbox push notification and get redirected to the corresponding inbox message. The inbox data is added to the push notification payload. However, due to Apple’s payload size restrictions, all inbox fields can’t be added to the push payload. Nevertheless, users are still redirected to the message without issues, and all fields become available when they return to the inbox.
Initially, these fields aren’t available in the Alert + Inbox Message dictionary:
sendDateUtcstartDateUtcendDateUtcsubjectstatusDirtyTo automatically mark an inbox message as read when a user taps on an inbox push notification, enable or disable the setMarkMessageReadOnInboxNotificationOpen feature in the PushConfigBuilder.
To sort inbox messages in your inbox implementation, use the value of sendDateUtc from the inbox message returned by getAllMessages and other getters.
When the application receives an Alert + Inbox notification while it’s in the foreground, call the refreshMessages method to fetch the latest inbox messages. This step ensures that the UI containsthe most recent content. For an example, see the iOS LearningApp.