Inbox object
The notifications of the Inbox will have the following states of the class InboxStatus:
- Sent : The notification has been sent to the client, whether or not they could read it.
- Click: have clicked on the notification displayed in the Inbox.
- Delete : The Inbox notification has been deleted by the customer.
The notifications will also come with a 'read' status, to help differentiate those status.
Each notification will be assigned with an integer and unique sendingId, to be able to differentiate them and use them for some of the functionalities.
In the particular case of Android, when a new push from Indigitall arrives at the client device, an action defined in an intent is generated, which can be used to notify the user that they have a new message in the Inbox. To collect it, it must be implemented in the following way:
@Override
protected void onResume() {
super.onResume();
if (getIntent() != null && getIntent().getExtras() != null){
Bundle extras = getIntent().getExtras();
if( extras != null && extras.containsKey(Push.EXTRA_PUSH)) {
//DO SOMETHING
}
}
}
As explained above, to obtain the notifications the following method is used:
Inbox.Companion.getInbox(context, new InboxCallback(context) {
@Override
public void onSuccess(Inbox inbox) {
//DO SOMETHING
}
@Override
public void onError(Error error) {
//LOG ERROR
}
});
Inbox next page
Once the Inbox instance is obtained, we will use it to request the next page, which is made with the following method, in the event that there are no more pages it will indicate it in the error with code 410:
inbox.getNextPage(context,new InboxCallback() {
@Override
public void onSuccess(Inbox inbox, newNotifications: ArrayList<InboxNotification>?) {
//DO SOMETHING
}
@Override
public void onError(Error error) {
if (error.code == 410){
//LOG NO HAY MÁS PÁGINAS
}else{
//LOG ERROR
}
}
});
Take into account that the Inbox callback, apart from returning the updated Inbox, returns an array called newNotifications, in which the new notifications to be added to the Inbox will be displayed, so that, if necessary, be able to use said array to move between the pages without depending on the Inbox calls.