SDKsAndroid
Track the total unread count
Use getTotalUnreadMsgCount() to retrieve the total unread count for the current Android account.
getTotalUnreadMsgCount() returns the complete unread snapshot for the signed-in account. Do not sum unreadCount values from only the currently loaded conversation pages.
OpenIMClient.getInstance().conversationManager.getTotalUnreadMsgCount(
new OnBase<String>() {
@Override
public void onSuccess(String value) {
int totalUnread = Integer.parseInt(value);
updateApplicationBadge(totalUnread);
}
@Override
public void onError(int code, String error) {
recordTotalUnreadFailure(code, error);
}
}
);The callback value is a String; handle parse failures as an application error rather than treating it as a partial list total. This page owns OnConversationListener.onTotalUnreadMessageCountChanged(int count), which updates the application badge after the initial query.
Was this page helpful?