getUnreadMessageCountForGroup static method
Gives count of unread messages for every one-on-one and group conversation.
on Success will return 2 keys:
- user - The value for this key holds another map that holds the UIDs of users and their corresponding unread message counts.
- group - The value for this key holds another map that holds the GUIDs of groups and their corresponding unread message counts.
method could throw PlatformException with error codes specifying the cause
Implementation
static Future<Map<String, int>?> getUnreadMessageCountForGroup({required String guid, bool? hideMessagesFromBlockedUsers, Function(Map<String, int> message)? onSuccess, Function(CometChatException excep)? onError}) async {
try {
final count = await channel.invokeMethod(
'getUnreadMessageCountForGroup', {
'guid': guid,
'hideMessagesFromBlockedUsers': hideMessagesFromBlockedUsers
});
final res = Map<String, int>.from(count);
if(onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
return null;
} catch (e) {
debugPrint("Error: $e");
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
return null;
}
}