InboxManager

public class InboxManager

The InboxManager provides the API to manage the inbox.

  • After the messages are loaded, it holds all the messages.

    Declaration

    Swift

    public var allMessages: [InboxMessage]
  • List of all messages: Unread and replied

    Declaration

    Swift

    public static var allMessages: [InboxMessage] { get }
  • Date for the last time messages were refreshed from the server.

    Declaration

    Swift

    public static var lastRefreshedTime: Date? { get }
  • Subscribe to changes in messages. The provided closure will be run with the latest list of messages. The first time the method is called, the closure will be executed with the current list of messages.

    Declaration

    Swift

    public static func subscribeToMessageChanges(updateBlock: @escaping ([InboxMessage]?) -> Void)
    Parameters
    updateBlock

    An update block the will be run whenever messages list is modified.

  • Reload messages from the server. -NOTE: The completion block is not required if the caller is subscribed to changes to messages with the method InboxMAnager.subscribeToMessageChanges(updateBlock:)

    Declaration

    Swift

    public static func reloadMessages(completion: (([InboxMessage]?, UsherErrorProtocol?) -> Void)? = nil)
    Parameters
    completion

    A completion block that will be called once downloading of messags from the server is complete.

  • Reply to an inbox message

    Declaration

    Swift

    public static func replyToMessage(message: InboxMessage,
                                      option: Int,
                                      completion: ((Bool, UsherErrorProtocol?) -> Void)?)
    Parameters
    message

    The message to reply to

    option

    The selected reply option index. Set this value to -1 for generic messages with not options but only confirm

    completion

    Optional completion block to be notified when repling is complete.