getOnlineUserCount static method

Future<int?> getOnlineUserCount({
  1. required dynamic onSuccess(
    1. int count
    )?,
  2. required dynamic onError(
    1. CometChatException excep
    )?,
})

get the total count of online users for your app

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<int?> getOnlineUserCount({required Function(int count)? onSuccess, required Function(CometChatException excep)? onError}) async {
  try {
    final result = await channel.invokeMethod('getOnlineUserCount', {});
    if(onSuccess != null) onSuccess(result);
    return result;
  } on PlatformException catch (platformException) {
    if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
  } catch (e) {
    debugPrint("Error: $e");
    if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
  }
  return null;
}