Skip to main content

Conversation Unread Count

Get Total Unread Count​

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

Method​

Future<int> getTotalUnreadCount(String? channelId, {IRCIMIWGetTotalUnreadCountCallback? callback});

Parameter Description​

ParameterTypeDescription
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetTotalUnreadCountCallbackCallback for the unread count retrieval event. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods are deprecated as of version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>The status code of the operation. 0 indicates success, while non-zero values indicate failure. Detailed errors can be found in the error codes.

Code Example​

IRCIMIWGetTotalUnreadCountCallback? callback = IRCIMIWGetTotalUnreadCountCallback(onSuccess: (int? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getTotalUnreadCount(channelId, callback:callback);

Callback Method​

  • onTotalUnreadCountLoaded
Function(int? code, String? channelId, int? count)? onTotalUnreadCountLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, while non-zero values indicate exceptions.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
countintThe unread count.

Code Example

engine?.onTotalUnreadCountLoaded = (int? code, String? channelId, int? count) {
//...
};

Get Unread Count for a Specific Conversation​

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

Method​

Future<int> getUnreadCount(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWGetUnreadCountCallback? callback});

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetUnreadCountCallbackCallback for the unread count retrieval event. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods are deprecated as of version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>The status code of the operation. 0 indicates success, while non-zero values indicate failure. Detailed errors can be found in the error codes.

Code Example​

IRCIMIWGetUnreadCountCallback? callback = IRCIMIWGetUnreadCountCallback(onSuccess: (int? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getUnreadCount(type, targetId, channelId, callback:callback);

Callback Method​

  • onUnreadCountLoaded
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? count)? onUnreadCountLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, while non-zero values indicate exceptions.
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
countintThe unread count.

Code Example

engine?.onUnreadCountLoaded = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? count) {
//...
};

Get Unread Count by Conversation Types​

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

Method​

Future<int> getUnreadCountByConversationTypes(List<RCIMIWConversationType> conversationTypes, String? channelId, bool contain, {IRCIMIWGetUnreadCountByConversationTypesCallback? callback});

Parameter Description​

ParameterTypeDescription
conversationTypesList<RCIMIWConversationType>The collection of conversation types.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
containboolWhether to include the unread count of muted messages.
callbackIRCIMIWGetUnreadCountByConversationTypesCallbackCallback for the event. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods are deprecated as of version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>The status code of the operation. 0 indicates success, while non-zero values indicate failure. Detailed errors can be found in the error codes.

Code Example​

IRCIMIWGetUnreadCountByConversationTypesCallback? callback = IRCIMIWGetUnreadCountByConversationTypesCallback(onSuccess: (int? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getUnreadCountByConversationTypes(conversationTypesInt, channelId, contain, callback:callback);

Callback Method​

  • onUnreadCountByConversationTypesLoaded
Function(int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, bool? contain, int? count)? onUnreadCountByConversationTypesLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, while non-zero values indicate exceptions.
conversationTypesList<RCIMIWConversationType>The collection of conversation types.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
containboolWhether to include the unread count of muted messages.
countintThe unread count.

Code Example

engine?.onUnreadCountByConversationTypesLoaded = (int? code, List<RCIMIWConversationType>? conversationTypes, String? channelId, bool? contain, int? count) {
//...
};

Clear Unread Count for a Specific Conversation​

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

Method​

Future<int> clearUnreadCount(RCIMIWConversationType type, String targetId, String? channelId, int timestamp, {IRCIMIWClearUnreadCountCallback? callback});

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
timestampintThe timestamp of the last read message in the conversation. Pass the current latest timestamp to clear all.
callbackIRCIMIWClearUnreadCountCallbackCallback for the event. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods are deprecated as of version 5.4.0. If a callback is provided, only the callback will be triggered.

Return Value​

Return ValueDescription
Future<int>The status code of the operation. 0 indicates success, while non-zero values indicate failure. Detailed errors can be found in the error codes.

Code Example​

IRCIMIWClearUnreadCountCallback? callback = IRCIMIWClearUnreadCountCallback(onUnreadCountCleared: (int? code) {
//...
});

int? ret = await engine?.clearUnreadCount(type, targetId, channelId, timestamp, callback:callback);

Callback Method​

  • onUnreadCountCleared
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? timestamp)? onUnreadCountCleared;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, while non-zero values indicate exceptions.
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
timestampintThe timestamp of the last read message in the conversation.

Code Example

engine?.onUnreadCountCleared = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? timestamp) {
//...
};

Load All @Unread Counts​

Loads all @unread counts for a specific conversation.

Method​

Future<int> getUnreadMentionedCount(RCIMIWConversationType type, String targetId, String? channelId, {IRCIMIWGetUnreadMentionedCountCallback? callback});

Parameter Description​

ParameterTypeDescription
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
callbackIRCIMIWGetUnreadMentionedCountCallbackCallback for the @unread count retrieval event. The SDK supports callback-based responses starting from version 5.3.1. Other callback methods are deprecated as of version 5.4.0. If a callback is provided, only the callback will be triggered.

Code Example​

IRCIMIWGetUnreadMentionedCountCallback? callback = IRCIMIWGetUnreadMentionedCountCallback(onSuccess: (int? t) {
//...
}, onError: (int? code) {
//...
});

int? ret = await engine?.getUnreadMentionedCount(type, targetId, channelId, callback:callback);

Callback Method​

  • onUnreadMentionedCountLoaded
Function(int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? count)? onUnreadMentionedCountLoaded;

Parameter Description

ParameterTypeDescription
codeintThe status code of the callback. 0 indicates success, while non-zero values indicate exceptions.
typeRCIMIWConversationTypeThe conversation type.
targetIdStringThe conversation ID.
channelIdStringChannel ID, only supported for ultra groups. Pass null for other conversation types.
countintThe unread count.

Code Example

engine?.onUnreadMentionedCountLoaded = (int? code, RCIMIWConversationType? type, String? targetId, String? channelId, int? count) {
//...
};