InboxMessageManager
Reads and manages Inbox messages, from both Marketing Cloud servers (MCE and MAM). Get the instance from InboxFeature.getInboxMessageManager; configure the feature with com.salesforce.marketingcloud.inboxfeature.config.InboxFeatureConfig.
A message is active from its start date until its end date, if it has one. The query and count methods only see active messages. MAM messages are scoped to the currently identified user (or to the anonymous user when none is set); MCE messages are shared by all users of the device.
Threading: the query and count methods (getMessages, getUnreadMessages, getReadMessages, getDeletedMessages and the get*Count methods) read and decrypt the local database synchronously on the calling thread, so they are annotated WorkerThread: call them off the main thread, e.g. withContext(Dispatchers.IO) { manager.getMessages() }, and post the result to the UI. The mutations and track methods only queue their work on an SDK background thread, and every listener is called on the main thread.
While Inbox is disabled (isInboxEnabled is false: blocked by privacy mode, disableInbox, or disabled in the config) the query methods return an empty list, the count methods return 0, the mutations and track methods are ignored (logged), and refreshInbox is refused. Registered listeners are kept but not called; the first fetch after Inbox is enabled again notifies them.
Types
Notified upon completion of a refreshInbox attempt, at most once per source.
Notified when a fetch delivers a fresh set of Inbox messages.
Functions
Marks message deleted in local storage. It is returned by getDeletedMessages instead of getMessages. The status persists until the message changes on the server or local storage is cleared.
Marks the message with messageId deleted in local storage. It is returned by getDeletedMessages instead of getMessages. The status persists until the message changes on the server or local storage is cleared.
Disables the Inbox feature at runtime. Stored messages are kept but hidden until enabled. The choice is persisted across restarts and takes precedence over com.salesforce.marketingcloud.inboxfeature.config.InboxFeatureConfig.inboxEnabled.
Enables the Inbox feature at runtime. The choice is persisted across restarts and takes precedence over com.salesforce.marketingcloud.inboxfeature.config.InboxFeatureConfig.inboxEnabled. Refused while GDPR-blocked.
Returns the number of active, deleted Inbox messages regardless of read status. Reads the local database on the calling thread; call it off the main thread.
Returns the active, deleted Inbox messages ordered by start date descending. Reads the local database on the calling thread; call it off the main thread.
Returns the total number of active, not-deleted Inbox messages regardless of read status. Reads the local database on the calling thread; call it off the main thread.
Returns the active, not-deleted Inbox messages ordered by start date descending. Reads the local database on the calling thread; call it off the main thread.
Returns the number of active, read, not-deleted Inbox messages. Reads the local database on the calling thread; call it off the main thread.
Returns the active, read, not-deleted Inbox messages ordered by start date descending. Reads the local database on the calling thread; call it off the main thread.
Returns the number of active, unread, not-deleted Inbox messages. Reads the local database on the calling thread; call it off the main thread.
Returns the active, unread, not-deleted Inbox messages ordered by start date descending. Reads the local database on the calling thread; call it off the main thread.
Returns true if the Inbox feature is currently enabled for this device. A GDPR block takes precedence over the runtime choice (enableInbox / disableInbox), which takes precedence over com.salesforce.marketingcloud.inboxfeature.config.InboxFeatureConfig.inboxEnabled.
Marks all active Inbox messages deleted.
Marks all active, unread, not-deleted Inbox messages read.
Requests an updated list of Inbox messages from Marketing Cloud. listener, if provided, is notified at most once per source for this call: once for each configured server (MCE, MAM) whose fetch completes, tagged with that server. Once the first server answers, a new refresh may be started; doing so stops this listener from receiving the remaining server's outcome. Outcomes are not matched to a specific call: a server's next outcome goes to the latest refresh's listener, even if it comes from a fetch started earlier. If the module itself refuses or cancels the request (a refresh is already in progress, Inbox is disabled or GDPR-blocked, or Inbox is disabled/torn down before any server has answered), listener is notified once with (false, Event.Producer.INBOX_FEATURE_MODULE). If Inbox is disabled/torn down after one server has answered, listener is released without a callback for the other server. Every listener callback, including a refusal, is made on the main thread after this call returns.
Registers a InboxResponseListener to be notified when a fetch delivers a fresh set of Inbox messages. The SDK holds listener until it is unregistered, so call unregisterInboxResponseListener when its owner is destroyed. Registering the same instance again has no effect.
Marks message read in local storage. The status persists until the message changes on the server or local storage is cleared. A deleted message is left unchanged.
Marks the message with messageId read in local storage. The status persists until the message changes on the server or local storage is cleared. A deleted message is left unchanged.
Records that message was interacted with (a button/CTA click) via interaction. The message is validated against the module store before an interaction is recorded; interacting with an unknown message is a no-op.
Records that message was opened by the app. The message is validated against the module store before an open is recorded; opening an unknown message is a no-op. This records the open analytic only — it does not mark the message read (that is the caller's responsibility).
Stops listener from receiving any further refreshInbox callbacks and releases the SDK's reference to it. Call this when the owner of listener is destroyed, so the SDK does not keep it (and anything it captures) alive while waiting for a server that may answer late or never.
Unregisters a previously registered InboxResponseListener.