/ SDKs / JavaScript
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
Version 4

Retrieve number of members who haven't read a message

Copy link

By using the getUnreadMemberCount() method, you can get the number of members who haven't read a specific message in a group channel. To get the most up-to-date value, the channel should be updated first through markAsRead() before calling the getUnreadMemberCount() method.

const count = channel.getUnreadMemberCount();
// ...

// To listen to an update from all client apps of channel members, implement the onUnreadMemberStatusUpdated() method with following behaviors to perform when notified.
const channelHandler = new GroupChannelHandler({
    onUnreadMemberStatusUpdated: (channel) => {
        // ...
        for (const message of messages) {
            const unreadCount = channel.getUnreadMemberCount(message);
            if (unreadCount <= 0) {
            // All members have read the message.
            } else {
            // Some of members haven't read the message yet.
sb.groupChannel.addGroupChannelHandler(UNIQUE_HANDLER_ID, channelHandler);