public class

RichPushInbox

extends AirshipComponent
java.lang.Object
   ↳ com.urbanairship.AirshipComponent
     ↳ com.urbanairship.richpush.RichPushInbox

Class Overview

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

Summary

Nested Classes
interface RichPushInbox.FetchMessagesCallback A callback used to be notified when refreshing messages. 
interface RichPushInbox.Listener A listener interface for receiving event callbacks related to inbox updates. 
interface RichPushInbox.Predicate Predicate interface for RichPushMessage
Constants
String MESSAGE_DATA_SCHEME Scheme used for @{code message:} when requesting to view a message with com.urbanairship.VIEW_RICH_PUSH_MESSAGE.
String VIEW_INBOX_INTENT_ACTION Intent action to view the rich push inbox.
String VIEW_MESSAGE_INTENT_ACTION Intent action to view a rich push message.
Public Methods
void addListener(RichPushInbox.Listener listener)
Subscribe a listener for inbox update event callbacks.
void deleteMessages(Set<String> messageIds)
Mark RichPushMessages deleted.
void fetchMessages()
Fetches the latest inbox changes from Urban Airship.
Cancelable fetchMessages(RichPushInbox.FetchMessagesCallback callback, Looper looper)
Fetches the latest inbox changes from Urban Airship.
Cancelable fetchMessages(RichPushInbox.FetchMessagesCallback callback)
Fetches the latest inbox changes from Urban Airship.
int getCount()
Gets the total message count.
RichPushMessage getMessage(String messageId)
Get the RichPushMessage with the corresponding message ID.
Set<String> getMessageIds()
Gets all the message ids in the inbox.
List<RichPushMessage> getMessages(RichPushInbox.Predicate predicate)
Gets a list of RichPushMessages, filtered by the provided predicate.
List<RichPushMessage> getMessages()
Gets a list of RichPushMessages.
int getReadCount()
Gets the total read message count.
List<RichPushMessage> getReadMessages()
Gets a list of read RichPushMessages.
List<RichPushMessage> getReadMessages(RichPushInbox.Predicate predicate)
Gets a list of read RichPushMessages, filtered by the provided predicate.
int getUnreadCount()
Gets the total unread message count.
List<RichPushMessage> getUnreadMessages()
Gets a list of unread RichPushMessages.
List<RichPushMessage> getUnreadMessages(RichPushInbox.Predicate predicate)
Gets a list of unread RichPushMessages, filtered by the provided predicate.
RichPushUser getUser()
Returns the RichPushUser.
void markMessagesRead(Set<String> messageIds)
Mark RichPushMessages read in bulk.
void markMessagesUnread(Set<String> messageIds)
Mark RichPushMessages unread in bulk.
void removeListener(RichPushInbox.Listener listener)
Unsubscribe a listener for inbox update event callbacks.
void startInboxActivity()
Starts an activity that can display the Message Center.
void startMessageActivity(String messageId)
Starts an activity that can display a RichPushMessage.
Protected Methods
void init()
Initialize the manager.
void tearDown()
Tear down the manager.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String MESSAGE_DATA_SCHEME

Scheme used for @{code message:} when requesting to view a message with com.urbanairship.VIEW_RICH_PUSH_MESSAGE.

Constant Value: "message"

public static final String VIEW_INBOX_INTENT_ACTION

Intent action to view the rich push inbox.

Constant Value: "com.urbanairship.VIEW_RICH_PUSH_INBOX"

public static final String VIEW_MESSAGE_INTENT_ACTION

Intent action to view a rich push message.

Constant Value: "com.urbanairship.VIEW_RICH_PUSH_MESSAGE"

Public Methods

public void addListener (RichPushInbox.Listener listener)

Subscribe a listener for inbox update event callbacks.

Parameters
listener An object implementing the RichPushInbox.Listener interface.

public void deleteMessages (Set<String> messageIds)

Mark RichPushMessages 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 void fetchMessages ()

Fetches the latest inbox changes from Urban 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 (RichPushInbox.FetchMessagesCallback callback, Looper looper)

Fetches the latest inbox changes from Urban 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.
looper The looper to post the callback on.
Returns
  • A cancelable object that can be used to cancel the callback.

public Cancelable fetchMessages (RichPushInbox.FetchMessagesCallback callback)

Fetches the latest inbox changes from Urban 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 int getCount ()

Gets the total message count.

Returns
  • The number of RichPushMessages currently in the inbox.

public RichPushMessage getMessage (String messageId)

Get the RichPushMessage with the corresponding message ID.

Parameters
messageId The message ID of the desired RichPushMessage.
Returns

public Set<String> getMessageIds ()

Gets all the message ids in the inbox.

Returns
  • A set of message ids.

public List<RichPushMessage> getMessages (RichPushInbox.Predicate 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

public List<RichPushMessage> 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<RichPushMessage> getReadMessages ()

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

Returns

public List<RichPushMessage> getReadMessages (RichPushInbox.Predicate 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<RichPushMessage> getUnreadMessages ()

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

Returns

public List<RichPushMessage> getUnreadMessages (RichPushInbox.Predicate 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 RichPushUser getUser ()

Returns the RichPushUser.

Returns

public void markMessagesRead (Set<String> messageIds)

Mark RichPushMessages read in bulk.

Parameters
messageIds A set of message ids.

public void markMessagesUnread (Set<String> messageIds)

Mark RichPushMessages unread in bulk.

Parameters
messageIds A set of message ids.

public void removeListener (RichPushInbox.Listener listener)

Unsubscribe a listener for inbox update event callbacks.

Parameters
listener An object implementing the RichPushInbox.Listener interface.

public void startInboxActivity ()

Starts an activity that can display the Message Center. An implicit intent with the intent action com.urbanairship.VIEW_RICH_PUSH_INBOX will be attempted first. If the intent fails to start an activity, the MessageCenterActivity will be started instead.

public void startMessageActivity (String messageId)

Starts an activity that can display a RichPushMessage. An implicit intent with the intent action com.urbanairship.VIEW_RICH_PUSH_INBOX with the message ID supplied as the data in the form of message:<MESSAGE_ID> will be attempted first. If the intent fails then the action com.urbanairship.VIEW_MESSAGE_INTENT_ACTION will be tried. Finally, it will fall back to the MessageActivity activity.

Parameters
messageId An ID of a RichPushMessage to display.

Protected Methods

protected void init ()

Initialize the manager. Called in UAirship during takeoff.

protected void tearDown ()

Tear down the manager. Called in UAirship during land.