getOnlineGroupMemberCount static method
get the total count of online users in particular groups Get online member count for multiple groups.
Migration Note: Migrated from platform channels to native Dart implementation. Uses PresenceRepository for getting online group member counts. Behavior and signature remain identical for backward compatibility.
Android Reference: CometChat.getOnlineGroupMemberCount(List<String> guids, CallbackListener<HashMap<String, Integer>>)
guids list of group ids
method could throw PlatformException with error codes specifying the cause
Implementation
static Future<Map<String, int>?> getOnlineGroupMemberCount(List<String> guids,
{required Function(Map<String, int> result)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call native Dart presence repository
// **Android Reference:** Uses same endpoint as getOnlineUserCount with groups body
final result = await sdk.presence.getOnlineGroupMemberCount(guids);
// Call success callback
if (onSuccess != null) onSuccess(result);
return result;
} on SdkException catch (sdkEx) {
// Convert SdkException to CometChatException
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}