Implement Inbox Messaging on iOS
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 PushConfigBuilder
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.
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:
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.
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:
sendDateUtc
startDateUtc
endDateUtc
subject
statusDirty
To 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, it's recommended to call the refreshMessages
method to fetch the latest inbox messages. Doing so ensures the UI stays updated with the most recent content. For more information, review the sample implementation in the iOS LearningApp.