InboxFeature

@objc(SFInboxFeature)
public final class InboxFeature : NSObject, SFMCModule
extension InboxFeature: Subscriber
extension InboxFeature: Publisher
extension InboxFeature: InboxFeatureApi
extension InboxFeature: InboxFeatureProtocol

Main entry point for the Inbox feature module.

Request SDK

  • Requests the Inbox Feature Module when it’s operational and safe to use. The provided callback will be invoked with the Inbox Feature Module when it’s ready. All Inbox feature module-related API calls should be made within this function.

    Declaration

    Swift

    @objc
    public static func requestSdk(_ callback: @escaping (_ inboxFeature: InboxFeatureApi?) -> Void)

    Parameters

    callback

    A callback that will receive the Inbox Feature Module when it’s operational/ready.

Reads

  • Returns all active Inbox messages already downloaded.

    Active messages are within their start and end dates and are not deleted.

    Declaration

    Swift

    public func getAllMessages() -> [InboxMessage]

    Return Value

    Inbox messages, or an empty array when the module is not operational or Inbox is disabled.

  • Returns unread active Inbox messages already downloaded.

    Declaration

    Swift

    public func getUnreadMessages() -> [InboxMessage]

    Return Value

    Unread Inbox messages, or an empty array when the module is not operational or Inbox is disabled.

  • Returns active Inbox messages marked as read.

    Declaration

    Swift

    public func getReadMessages() -> [InboxMessage]

    Return Value

    Read Inbox messages, or an empty array when the module is not operational or Inbox is disabled.

  • Returns active Inbox messages marked as deleted.

    Declaration

    Swift

    public func getDeletedMessages() -> [InboxMessage]

    Return Value

    Deleted Inbox messages, or an empty array when the module is not operational or Inbox is disabled.

Counts

  • Returns the count of all active Inbox messages already downloaded.

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Swift

    public func getAllMessagesCount() -> Int

    Return Value

    The number of messages, or 0 when the module is not operational or Inbox is disabled.

  • Returns the count of unread active Inbox messages already downloaded.

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Swift

    public func getUnreadMessagesCount() -> Int

    Return Value

    The number of messages, or 0 when the module is not operational or Inbox is disabled.

  • Returns the count of active Inbox messages marked as read.

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Swift

    public func getReadMessagesCount() -> Int

    Return Value

    The number of messages, or 0 when the module is not operational or Inbox is disabled.

  • Returns the count of active Inbox messages marked as deleted.

    Useful for inbox count badges or other interface elements, without having to fetch messages directly.

    Declaration

    Swift

    public func getDeletedMessagesCount() -> Int

    Return Value

    The number of messages, or 0 when the module is not operational or Inbox is disabled.

Mutations

  • Marks an Inbox message as read.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled. A deleted message stays deleted. The read state is synced to the server on the next status update.

    Declaration

    Swift

    public func markMessageRead(id: String) -> Bool

    Parameters

    id

    The Inbox message identifier.

    Return Value

    true if the message was marked read. false if the module is not operational, Inbox is disabled, or the identifier is unknown.

  • Marks an Inbox message as deleted.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled. Deletion takes precedence over read when the status is synced to the server.

    Declaration

    Swift

    public func markMessageDeleted(id: String) -> Bool

    Parameters

    id

    The Inbox message identifier.

    Return Value

    true if the message was marked deleted. false if the module is not operational, Inbox is disabled, or the identifier is unknown.

  • Marks an Inbox message as read.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled.

    Declaration

    Swift

    public func markMessageRead(message: InboxMessage) -> Bool

    Parameters

    message

    The Inbox message to mark as read.

    Return Value

    true if the message was marked read. false if the module is not operational, Inbox is disabled, or the message is unknown.

  • Marks an Inbox message as deleted.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled.

    Declaration

    Swift

    public func markMessageDeleted(message: InboxMessage) -> Bool

    Parameters

    message

    The Inbox message to mark as deleted.

    Return Value

    true if the message was marked deleted. false if the module is not operational, Inbox is disabled, or the message is unknown.

  • Marks all active Inbox messages as read.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled.

    Declaration

    Swift

    public func markAllMessagesRead() -> Bool

    Return Value

    true if messages were marked read. false if the module is not operational, Inbox is disabled, or there were no unread messages.

  • Marks all active Inbox messages as deleted.

    This state is persisted locally and is reset if the SDK’s data is reset, for example after the app is deleted and reinstalled.

    Declaration

    Swift

    public func markAllMessagesDeleted() -> Bool

    Return Value

    true if messages were marked deleted. false if the module is not operational, Inbox is disabled, or there were no messages to delete.

Refresh

  • Reloads Inbox messages from each operational producer (Marketing Cloud Engagement, Mobile App Messaging, or both).

    Manual refresh is limited to one request per minute. A call made before that interval elapses, while Inbox is disabled, or while the module is not operational completes with false and MessageProducer/inboxFeature.

    During server-side throttling a producer may answer 429 - Too Many Requests. That failure is delivered through completion and is not sent to InboxResponseDelegate.

    The completion is invoked once for each expected producer. Success and failure from a producer are delivered on the main queue. A refused refresh stays on the calling thread.

    Declaration

    Swift

    public func refreshMessages(_ completion: ((Bool, MessageProducer) -> Void)?)

    Parameters

    completion

    Optional one-shot callback. Pass nil to refresh without completion callbacks. Registering a completion does not replace an InboxResponseDelegate.

  • Registers for successful Inbox downloads.

    The SDK retains delegate until unregisterInboxResponseDelegate(_:). No-op if the module is not operational. Failures are not delivered here. Use the refreshMessages completion for refresh outcomes.

    Declaration

    Swift

    public func registerInboxResponseDelegate(_ delegate: InboxResponseDelegate)

    Parameters

    delegate

    The object to notify after a producer persists Inbox messages.

  • Removes a previously registered response delegate.

    No-op if the module is not operational or the delegate was not registered.

    Declaration

    Swift

    public func unregisterInboxResponseDelegate(_ delegate: InboxResponseDelegate)

    Parameters

    delegate

    The delegate to remove.

Analytics

  • Records that the user opened an Inbox message.

    No-op if the module is not operational or Inbox is disabled. This does not mark the message as read. Call markMessageRead(message:) to update read state.

    Declaration

    Swift

    public func trackMessageOpenEvent(_ message: InboxMessage)

    Parameters

    message

    The Inbox message that was opened.

  • Records a tap on an Inbox message call to action or button.

    No-op if the module is not operational or Inbox is disabled.

    Declaration

    Swift

    public func trackMessageInteractionEvent(_ message: InboxMessage, interaction: InboxMessageInteraction)

    Parameters

    message

    The Inbox message that was tapped.

    interaction

    The tapped object. Use InboxInteractionType/cta for the message action and InboxInteractionType/button with the button identifier for a button.

Feature Toggle

  • Enables or disables Inbox processing for this app.

    Disabling Inbox cancels a refresh that is still waiting for producers. It does not delete messages already downloaded. While Inbox is disabled, reads return empty results, mutations return false, analytics no-op, and refreshMessages completes with false. No-op if the module is not operational.

    Declaration

    Swift

    public func setInboxEnabled(_ enabled: Bool)

    Parameters

    enabled

    Pass true to enable Inbox, or false to disable it.

  • Returns whether Inbox processing is enabled.

    Declaration

    Swift

    public func isInboxEnabled() -> Bool

    Return Value

    true when Inbox is enabled. false when it is disabled or the module is not operational.