Using the getUnreadMembers() 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 first be updated through markAsRead() before calling getUnreadMembers().
try {
// Call the markAsRead() method when the current user views unread messages in a group channel.
await groupChannel.markAsRead();
} catch (e) {
// Handle error.
}
// To listen to an update from all the other channel members' client apps, implement onReadStatusUpdated() with actions to do when notified.
class MyGroupChannelHandler with GroupChannelHandler {
@override
void onReadStatusUpdated(GroupChannel channel) {
if (currentGroupChannel.channelUrl == channel.channelUrl) {
messages.forEach((message) {
final unreadCount = channel.getUnreadMembers(message);
if (unreadCount <= 0) {
// 0 means that all members have read this message.
} else {
// If the value isn't 0,
// some members haven't read this message.
}
});
}
}
}