// Call the markAsRead method when the current user views
// unread messages in a group channel.
channel.markAsRead { error in
guard error == nil else {
// Handle error.
return
}
}
// To listen to an update from other channel members' client apps,
// implement the channelDidUpdateReadStatus(_:) function
// with actions to perform when notified.
class GroupChannelChattingViewController: UIViewController, GroupChannelDelegate {
func initViewController() {
SendbirdChat.add(self as GroupChannelDelegate, identifier: UNIQUE_DELEGATE_ID)
}
func channelDidUpdateReadStatus(_ channel: GroupChannel) {
if currentGroupChannel.channelURL == channel.channelURL {
for msg in messages {
let unreadCount = channel.getUnreadMemberCount(msg)
if unreadCount <= 0 {
// All members have read the message.
}
else {
// Some of members haven't read the message.
}
}
}
}
}