Skip to main content

Unread Message Count

Get Total Unread Count​

Get the total unread count for all conversation types (excluding chatrooms).

Method​


getTotalUnreadCount(
channelId: string,
callback: IRCIMIWGetTotalUnreadCountCallback
): Promise<number>;

Parameter Description​

Parameter NameParameter TypeDescription
channelIdstringThe channel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWGetTotalUnreadCountCallbackCallback for the interface call result.

Return Value​

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates success. For specific results, implement the interface callback. Non-zero indicates failure, and the callback won't be triggered. Refer to the error code for details.

Code Example​


const callback = {
onSuccess: (t: number) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getTotalUnreadCount(channelId, callback);

Get Unread Count for a Specific Conversation​

Get the unread message count for a specific conversation (excluding chatrooms).

Method​


getUnreadCount(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWGetUnreadCountCallback
): Promise<number>;

Parameter Description​

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringThe channel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWGetUnreadCountCallbackCallback for the interface call result.

Return Value​

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates success. For specific results, implement the interface callback. Non-zero indicates failure, and the callback won't be triggered. Refer to the error code for details.

Code Example​


const callback = {
onSuccess: (t: number) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getUnreadCount(type, targetId, channelId, callback);

Get Unread Count by Conversation Types​

Get the unread count for multiple specified conversation types (excluding chatrooms).

Method​


getUnreadCountByConversationTypes(
conversationTypes: Array<RCIMIWConversationType>,
channelId: string,
contain: boolean,
callback: IRCIMIWGetUnreadCountByConversationTypesCallback
): Promise<number>;

Parameter Description​

Parameter NameParameter TypeDescription
conversationTypesArray<RCIMIWConversationType>Collection of conversation types
channelIdstringThe channel ID, only supported for ultra groups. For other conversation types, pass null.
containbooleanWhether to include unread messages from muted conversations.
callbackIRCIMIWGetUnreadCountByConversationTypesCallbackCallback for the interface call result.

Return Value​

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates success. For specific results, implement the interface callback. Non-zero indicates failure, and the callback won't be triggered. Refer to the error code for details.

Code Example​


const callback = {
onSuccess: (t: number) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getUnreadCountByConversationTypes(conversationTypes, channelId, contain, callback);

Clear Unread Count for a Specific Conversation​

Clear the unread count for a specific conversation (excluding chatrooms).

Method​


clearUnreadCount(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
timestamp: number,
callback: IRCIMIWClearUnreadCountCallback
): Promise<number>;

Parameter Description​

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringThe channel ID, only supported for ultra groups. For other conversation types, pass null.
timestampnumberThe timestamp of the last read message in the conversation. To clear all, pass the latest timestamp.
callbackIRCIMIWClearUnreadCountCallbackCallback for the interface call result.

Return Value​

Return ValueDescription
numberThe status code of the current interface operation. 0 indicates success. For specific results, implement the interface callback. Non-zero indicates failure, and the callback won't be triggered. Refer to the error code for details.

Code Example​


const callback = {
onUnreadCountCleared: (code: number) => {
//...
},
};
let code = await engine.clearUnreadCount(type, targetId, channelId, timestamp, callback);

Load All Unread Mention Counts​

Load all unread mention counts for a specific conversation.

Method​


getUnreadMentionedCount(
type: RCIMIWConversationType,
targetId: string,
channelId: string,
callback: IRCIMIWGetUnreadMentionedCountCallback
): Promise<number>;

Parameter Description​

Parameter NameParameter TypeDescription
typeRCIMIWConversationTypeConversation type
targetIdstringConversation ID
channelIdstringThe channel ID, only supported for ultra groups. For other conversation types, pass null.
callbackIRCIMIWGetUnreadMentionedCountCallbackCallback for the interface call result.

Code Example​


const callback = {
onSuccess: (t: number) => {
//...
},
onError: (code: number) => {
//...
},
};
let code = await engine.getUnreadMentionedCount(type, targetId, channelId, callback);