Android custom inbox mobile

Implement a custom inbox in your Android application.

You can implement a custom inbox in your Android application by implementing a Custom Inbox Handler, which will allow you to retrieve the Inbox Feed that you can custom-handle to meet your requirements.

This is done using the InboxListListener interface and the inboxListWithOffset function.

The first step is to implement the InboxListListener in our Application.java class:

public class XPushApplication extends Application implements InboxListListener {

}

Following this step, implement it's inboxListReceived and inboxListFailed methods:

@Override
public void inboxListReceived(ArrayList<InboxMessageListItem> inboxList, WeakReference<Context> uiReference) {
 for (int i = 0; i < inboxList.size(); i++){
  	// do something  
 }
}

@Override
public void inboxListFailed() {

}

Then add a reference to this when implementing Xtremepush:

new PushConnector.Builder(XPUSH_APP_KEY, GOOGLE_PROJECT_NUMBER)
  .setInboxListListener(this)
  .create(this);

The inboxListReceived callback returns an array list of inboxMessageListItems which describe the inbox message. The structure of the inboxMessageListItem is as follows:

public int identifier;
public boolean isOpened;
public boolean isClicked; 
public Long createTimestamp;
public Long expirationTimestamp;
public HashMap<String, String> style;
public boolean isCard;
public Message message;

Following this, when you make a call using the inboxListWithOffset function, it will return a list of inbox messages to the InboxListListener callback:

mPushConnector.inboxListWithOffset(context, (int) LIMIT, (int) OFFSET);

Using the above, you can retrieve the inbox messages and handle them as required.

Delete an inbox message:

mPushConnector.deleteInboxMessage(String MessageID, Activity activity);\

Used to delete an inbox message.

mPushConnector.deleteInboxMessage( someMessageId, activity);

Get inbox badge number:

mPushConnector.getInboxBadge();

Returns cached inbox number as int.

int cachedInboxBadge = mPushConnector.getInboxBadge();

Report inbox message opened:

mPushConnector.reportMessageOpened(Message message, String action) mPushConnector.reportMessageOpened(Message message, String action, JSONObject message_context)

Used to mark an inbox message as opened on the platform. Can include additional context.

mPushConnector.reportMessageOpened(xpMessage, null, null);

Report inbox message clicked:

mPushConnector.reportMessageClicked(Message message, String action) mPushConnector.reportMessageClicked(Message message, String action, JSONObject message_context)

Used to mark an inbox message as clicked on the platform. This also automatically marks an inbox message as opened.

mPushConnector.reportMessageClicked(xpMessage, null, null);