getTotalUnreadMessageCount
Introduction
The total amount of unread messages.
You can call the this method to get the total unread count of all conversations.
You don't need to go through the conversation list and add up the unread count of each conversation to get the total unread count.
When the total unread count changes, the SDK will proactively call back onTotalUnreadMessageCountChanged to your app to notify you of the latest unread count.
IM SDK provides three APIs for the amount of unread messages to be emptied:
Mark a specific c2c conversation as read. markC2CMessageAsRead。
Mark a specific group chat as read. markGroupMessageAsRead。
Mark all message related to current users as read. Clear the total unread count. markAllMessageAsRead。
Parameter details
This API has no parameters
Returned template
V2TimValueCallback<number>
{
code : number
desc : string
data : number//The total amount of unread messages.
}
Return value details
name | type | description |
---|---|---|
code | number | Request result: Error codes. 0 means success. |
desc | string | The description of the error. It will be empty if success. |
data | number | The total amount of unread messages. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const getTotalUnreadMessageCountRes = await TencentImSDKPlugin.v2TIMManager
.getConversationManager()
.getTotalUnreadMessageCount();
if (getTotalUnreadMessageCountRes.code === 0) {
getTotalUnreadMessageCountRes.data;
}