getNotificationFeedUnreadCount static method

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

Gets the unread count for the notification feed.

Android Reference: CometChat.getNotificationFeedUnreadCount()

Returns the total number of unread notification feed items.

@param onSuccess Callback invoked with the unread count on success. @param onError Callback invoked if an error occurs.

Implementation

static Future<int?> getNotificationFeedUnreadCount(
    {required Function(int count)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final sdk = SdkRegistry.getInstance();
    final count = await sdk.notificationFeed.getUnreadCount();
    if (onSuccess != null) onSuccess(count);
    return count;
  } on SdkException catch (sdkEx) {
    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;
}