Implement Inbox Messaging on Android
The MobilePush SDK for Android provides convenience methods for refreshing the app inbox and managing messages, including retrieving, reading, and deleting them. For more information about these methods, see InboxMessageManager Method Reference.
These code examples show how to enable Inbox Messaging during the SDK initialization process. If you use version 10 of the SDK, use this code.
If you use version 8 of the SDK, use this code.
If you use version 7 or earlier of the SDK, use this code.
The MobilePush SDK offers these convenience methods for retrieving inbox messages:
Each method returns a list of InboxMessage Objects. A consuming application can access these properties within each message object.
| Key | Type | Nullable | SDK Version Availability |
|---|---|---|---|
id | String | No | Version 8 and later |
alert | String | Yes | Version 8 and later |
subject | String | Yes | Version 8 and later |
startDateUtc | Date | Yes | Version 8 and later |
sendDateUtc | Date | Yes | Version 8 and later |
endDateUtc | Date | Yes | Version 8 and later |
custom | String | Yes | Version 8 and later |
customKeys | Map<String,String> | Yes | Version 8 and later |
title | String | Yes | Version 8 and later |
url | String | Yes | Version 8 and later |
deleted | Boolean | No | Version 8 and later |
read | Boolean | No | Version 8 and later |
sound | String | Yes | Version 8 and later |
subtitle | String | Yes | Version 8 and later |
media | InboxMessage.Media | Yes | Version 8 and later |
inboxMessageType | Int | Yes | Version 9 and later |
inboxSubtitle | String | Yes | Version 9 and later |
inboxMessage | String | Yes | Version 9 and later |
notificationMessage | NotificationMessage | Yes | Version 9 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 Push Copy to Inbox (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 and requestId, are reserved for internal use. Don’t use these properties in your app.
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. Because of restrictions on the payload size, you can’t add all inbox fields to the push payload. However, 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:
sendDateUtcstartDateUtcendDateUtcsubject
To automatically mark an inbox message as read after a user taps an inbox push notification, enable the setMarkMessageReadOnInboxNotificationOpen feature in the PushConfigBuilder.
By default, if user taps on the notification for an Alert+Inbox message, the SDK marks the inbox message as read. You can toggle this behavior by changing the value of markMessageReadOnInboxNotificationOpen in MarketingCloudConfig.
The SDK doesn’t automatically present URLs from Alert+CloudPage push messages. To handle the URLs from these messages, customize notification handling for the app.
To sort inbox messages in your custom inbox implementation, use the value of sendDateUtc from the Inbox Message returned by getMessages.