Unread message count for groups not always working correctly

On group chats, the unread counts aren’t always being cleared correctly. The issue is very intermittent.
In our app, we are marking messages as delivered and read. We also handle the unread count locally to show that the unread count in the UI is set to 0 or “”. But the getUnreadMessageCount method from the CC SDK still returns the unread count of a message is greater than 0.

Hello @jeraldo,

It seems that messages are not marking as read properly. Please share short video of the issue along with the code snippet which you’ve added inside your app so that we can look into this asap.

here is the video: https://drive.google.com/file/d/10pgFGXVzdj5ig8_x3SqioYODHuteEGOc/view?usp=sharing

 func markMessageAsRead(_ message: BaseMessage) {
        print("Marking message with id \(message.id) as read.")
        switch self.receiverType {
          case .user:
            CometChat.markAsRead(messageId: message.id, receiverId: message.senderUid, receiverType: .user)
          case .group:
            CometChat.markAsRead(messageId: message.id, receiverId: message.receiverUid, receiverType: .group)
          @unknown default:
            break
        }
      }

In the video attached, we mark the last message of a conversation as read when we open the chat and fetch the messages. The unread count in the tableView is handled locally when marking them as read. Whenever we refresh the list, we also call getUnreadMessageCount to update the list’s unread count.

As you can see in the snippet, we are marking the messages correctly as read.
The issue happens intermittently on group messages. There are some days that when we mark them as read, the getUnreadMessageCount will return 0. But sometimes, even after marking the messages as read, it returns the same count.