Get total unread count
Retrieve the total unread message count across all conversations for the current account.
Retrieve the aggregated unread message count across all conversations for the active user account. The SDK tallies all stored conversations internally, preventing discrepancies that arise from manually summing the unreadCount of only the currently loaded page:
Code example
final value = await OpenIM.iMManager.conversationManager
.getTotalUnreadMsgCount();
final totalUnread = int.tryParse(value.toString()) ?? 0;
updateApplicationBadge(totalUnread);Return value
A successful Future returns the total unread message count for the current account. Use this value to update main navigation badges or app icon indicators.
State changes after the call
This query returns an immediate numerical snapshot and does not emit event callbacks. Subsequent unread count changes are delivered via onTotalUnreadMessageCountChanged on OnConversationListener. See Events overview for complete listener setup.
To synchronize this count with the native device application badge on supported platforms, see Set application badge.
Was this page helpful?