public class

Inbox

extends Object
java.lang.Object
   ↳ com.urbanairship.messagecenter.Inbox

Class Overview

The inbox provides access to the device's local inbox data. Modifications (e.g., deletions or mark read) will be sent to the Airship server the next time the inbox is synchronized.

Summary

Nested Classes
interface Inbox.FetchMessagesCallback A callback used to be notified when refreshing messages. 
Public Methods
void addListener(InboxListener listener)
Subscribe a listener for inbox update event callbacks.
void deleteMessages(Set<String> messageIds)
Mark Messages deleted.
Cancelable fetchMessages(Inbox.FetchMessagesCallback callback)
Fetches the latest inbox changes from Airship.
void fetchMessages()
Fetches the latest inbox changes from Airship.
Cancelable fetchMessages(Looper looper, Inbox.FetchMessagesCallback callback)
Fetches the latest inbox changes from Airship.
int getCount()
Gets the total message count.
Message getMessage(String messageId)
Get the Message with the corresponding message ID.
Message getMessageByUrl(String messageUrl)
Get the Message with the corresponding message body URL.
Set<String> getMessageIds()
Gets all the message ids in the inbox.
List<Message> getMessages(Predicate<Message> predicate)
Gets a list of RichPushMessages, filtered by the provided predicate.
List<Message> getMessages()
Gets a list of RichPushMessages.
int getReadCount()
Gets the total read message count.
List<Message> getReadMessages()
Gets a list of read RichPushMessages.
List<Message> getReadMessages(Predicate<Message> predicate)
Gets a list of read RichPushMessages, filtered by the provided predicate.
int getUnreadCount()
Gets the total unread message count.
List<Message> getUnreadMessages()
Gets a list of unread RichPushMessages.
List<Message> getUnreadMessages(Predicate<Message> predicate)
Gets a list of unread RichPushMessages, filtered by the provided predicate.
User getUser()
Returns the User.
void markMessagesRead(Set<String> messageIds)
Mark Messages read in bulk.
void markMessagesUnread(Set<String> messageIds)
Mark Messages unread in bulk.
void removeListener(InboxListener listener)
Unsubscribe a listener for inbox update event callbacks.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void addListener (InboxListener listener)

Subscribe a listener for inbox update event callbacks.

Parameters
listener An object implementing the InboxListener interface.

public void deleteMessages (Set<String> messageIds)

Mark Messages deleted.

Note that in most cases these messages aren't immediately deleted on the server, but they will be inaccessible on the device as soon as they're marked deleted.

Parameters
messageIds A set of message ids.

public Cancelable fetchMessages (Inbox.FetchMessagesCallback callback)

Fetches the latest inbox changes from Airship.

Normally this method is not called directly as the message list is automatically fetched when the application foregrounds or when a notification with an associated message is received.

If the fetch request completes and results in a change to the messages, onInboxUpdated() will be called.

Parameters
callback Callback to be notified when the request finishes fetching the messages.
Returns
  • A cancelable object that can be used to cancel the callback.

public void fetchMessages ()

Fetches the latest inbox changes from Airship.

Normally this method is not called directly as the message list is automatically fetched when the application foregrounds or when a notification with an associated message is received.

If the fetch request completes and results in a change to the messages, onInboxUpdated() will be called.

public Cancelable fetchMessages (Looper looper, Inbox.FetchMessagesCallback callback)

Fetches the latest inbox changes from Airship.

Normally this method is not called directly as the message list is automatically fetched when the application foregrounds or when a notification with an associated message is received.

If the fetch request completes and results in a change to the messages, onInboxUpdated() will be called.

Parameters
looper The looper to post the callback on.
callback Callback to be notified when the request finishes fetching the messages.
Returns
  • A cancelable object that can be used to cancel the callback.

public int getCount ()

Gets the total message count.

Returns
  • The number of RichPushMessages currently in the inbox.

public Message getMessage (String messageId)

Get the Message with the corresponding message ID.

Parameters
messageId The message ID of the desired Message.
Returns
  • A Message or null if one does not exist.

public Message getMessageByUrl (String messageUrl)

Get the Message with the corresponding message body URL.

Parameters
messageUrl The message body URL of the desired Message.
Returns
  • A Message or null if one does not exist.

public Set<String> getMessageIds ()

Gets all the message ids in the inbox.

Returns
  • A set of message ids.

public List<Message> getMessages (Predicate<Message> predicate)

Gets a list of RichPushMessages, filtered by the provided predicate. Sorted by descending sent-at date.

Parameters
predicate A predicate for filtering messages. If null, no predicate will be applied.
Returns
  • List of filtered and sorted Messages.

public List<Message> getMessages ()

Gets a list of RichPushMessages. Sorted by descending sent-at date.

Returns

public int getReadCount ()

Gets the total read message count.

Returns
  • The number of read RichPushMessages currently in the inbox.

public List<Message> getReadMessages ()

Gets a list of read RichPushMessages. Sorted by descending sent-at date.

Returns

public List<Message> getReadMessages (Predicate<Message> predicate)

Gets a list of read RichPushMessages, filtered by the provided predicate. Sorted by descending sent-at date.

Parameters
predicate A predicate for filtering messages. If null, no predicate will be applied.
Returns

public int getUnreadCount ()

Gets the total unread message count.

Returns
  • The number of unread RichPushMessages currently in the inbox.

public List<Message> getUnreadMessages ()

Gets a list of unread RichPushMessages. Sorted by descending sent-at date.

Returns

public List<Message> getUnreadMessages (Predicate<Message> predicate)

Gets a list of unread RichPushMessages, filtered by the provided predicate. Sorted by descending sent-at date.

Parameters
predicate A predicate for filtering messages. If null, no predicate will be applied.
Returns

public User getUser ()

Returns the User.

Returns

public void markMessagesRead (Set<String> messageIds)

Mark Messages read in bulk.

Parameters
messageIds A set of message ids.

public void markMessagesUnread (Set<String> messageIds)

Mark Messages unread in bulk.

Parameters
messageIds A set of message ids.

public void removeListener (InboxListener listener)

Unsubscribe a listener for inbox update event callbacks.

Parameters
listener An object implementing the InboxListener interface.