TIMConvGetTotalUnreadMessageCount
Introduction
Get total unread message count
Unread messages are messages that have not been reported as read by users. This does not indicate whether the recipient has actually read the messages.
To display the correct unread count, developers need to explicitly call read reports to notify the IM SDK whether the messages in a conversation are read.
For example, you can mark all messages as read when the user enters the chat UI.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
param | convGetTotalUnreadMessageCount | yes | Param of getting total unread message count |
Returned template
Promise<commonResult<totalUnreadCountResult>>
{
code: TIMResult | TIMErrCode;
desc?: string | undefined;
json_param?: totalUnreadCountResult | undefined;
json_params?: totalUnreadCountResult | undefined;
user_data?: string | undefined;
}
Return value details
name | type | description |
---|---|---|
code | TIMResult | TIMErrCode | Request result: Error codes. 0 means success. |
desc | string | undefined | The description of the error. It will be empty if success. |
json_param | totalUnreadCountResult | undefined | Return value of calling API |
json_params | totalUnreadCountResult | undefined | Return value of calling API. Compatible field, which is returned in some cases. |
user_data | string | undefined | ImSDK is responsible for transporting user-defined data without any processing |
Code example
import TimRender from "im_electron_sdk/dist/renderer";
const timRenderInstance = new TimRender();
import { convGetTotalUnreadMessageCount } from "im_electron_sdk/dist/interfaces";
let param: convGetTotalUnreadMessageCount = {
user_data: "", // optional
}
let { code } = await timRenderInstance.TIMConvGetTotalUnreadMessageCount(param)
if (code == 0) {
// success
}