Android App Inbox

App Inbox is similar to an email inbox but is designed for direct messages from an app. As opposed to push notifications, it allows customers to keep promotions and browse a chronological list of messages at any time.

With the Reteno App Inbox, there is no default UI. This means with a few lines of code, you can connect Reteno with your inbox.

📘

Note

SDK Version App Inbox is available in version 1.2.0 and later.

Reteno App Inbox

To get an instance to the AppInbox object, you need to use the Reteno instance:

AppInbox appInbox = reteno.getAppInbox()
val appInbox = reteno.appInbox

Downloading New Messages

// If  `page`  or  `pageSize`  is not specified, then all messages will be returned
appInbox.getAppInboxMessages(@Nullable Integer page, @Nullable Integer pageSize, new RetenoResultCallback<AppInboxMessages>() {
    @Override
    public void onSuccess(AppInboxMessages result) {
        List<AppInboxMessage> messages = result.getMessages();
        int totalPages = result.result.getTotalPages();
    }
    @Override
    public void onFailure(@Nullable Integer statusCode, @Nullable String response, @Nullable Throwable throwable) {
        // handle error
    }
});
// If  `page`  or  `pageSize`  is not specified, then all messages will be returned
appInbox.getAppInboxMessages(page: Int?, pageSize: Int?, object : RetenoResultCallback<AppInboxMessages> {
    override fun onSuccess(result: AppInboxMessages) {
        val messages = result.messages
        val totalPages = result.totalPages
    }
    override fun onFailure(statusCode: Int?, response: String?, throwable: Throwable?) {
        // handle error
    }
})

The result is an instance of the AppInboxMessages class:

data class AppInboxMessages(
    val messages: List<AppInboxMessage>,
    val totalPages: Int
)

Reteno inbox message attributes:

data class AppInboxMessage(
    val id: String,
    val title: String,
    val createdDate: String,
    val isNewMessage: Boolean,
    val content: String?,
    val imageUrl: String?,
    val linkUrl: String?,
    val category: String?
)

Get Inbox Unread Messages Count

appInbox.getAppInboxMessagesCount(new RetenoResultCallback<Integer>() {
    @Override
    public void onSuccess(Integer count) {
        // handle count
    }
    @Override
    public void onFailure(@Nullable Integer statusCode, @Nullable String response, @Nullable Throwable throwable) {
        // handle error
    }
});
appInbox.getAppInboxMessagesCount(object : RetenoResultCallback<Int> {
    override fun onSuccess(count: Int) {
        // handle count
    }
    override fun onFailure(statusCode: Int?, response: String?, throwable: Throwable?) {
        // handle error
    }
})

Subscribe on Inbox Unread Messages Count

appInbox.subscribeOnMessagesCountChanged(new RetenoResultCallback<Integer>() {
    @Override
    public void onSuccess(Integer count) {
        // handle count
    }
    @Override
    public void onFailure(@Nullable Integer statusCode, @Nullable String response, @Nullable Throwable throwable) {
        // handle error
    }
});
appInbox.subscribeOnMessagesCountChanged(object : RetenoResultCallback<Int> {
    override fun onSuccess(count: Int) {
        // handle count
    }
    override fun onFailure(statusCode: Int?, response: String?, throwable: Throwable?) {
        // handle error
    }
})

📘

Note

Don't forget to unsubscribe

// pass callback from subscribeOnMessagesCountChanged 
appInbox.unsubscribeMessagesCountChanged(RetenoResultCallback<Int> callback);
// or
appInbox.unsubscribeAllMessagesCountChanged();
// pass callback from subscribeOnMessagesCountChanged 
appInbox.unsubscribeMessagesCountChanged(callback: RetenoResultCallback<Int>)
// or
appInbox.unsubscribeAllMessagesCountChanged()

Change Inbox Message Status on OPENED

The status will be saved and sent during the next cache push session. See Force push locally cached data.

appInbox.markAsOpened(String messageId);
appInbox.markAsOpened(messageId: String)

Also you can change all inbox messages status via single method without providing messages ids.

appInbox.markAllMessagesAsOpened(new RetenoResultCallback<Unit>() {
    @Override
    public void onSuccess(Unit result) {
        // handle success
    }
    @Override
    public void onFailure(@Nullable Integer statusCode, @Nullable String response, @Nullable Throwable throwable) {
        // handle error
    }
});
appInbox.markAllMessagesAsOpened(object : RetenoResultCallback<Unit> {
    override fun onSuccess(result: Unit) {
        // handle success
    }
    override fun onFailure(statusCode: Int?, response: String?, throwable: Throwable?) {
        // hande error
    }
})