Mark messages as read
In a group channel, the read status of messages is crucial for understanding which messages have been read by which members. This document explains how to mark messages as read in a group channel.
To keep the most up-to-date and accurate read status of messages for all group channel members, the markAsRead()
method should be called in the following cases:
- When a channel member reads messages by entering the channel from a channel list.
- When a channel member switches the chat view from the background to the foreground.
Read receipts
When a channel member sends a message to the channel, the Sendbird server immediately updates the sender's read receipt to the time when the message was sent. The read receipts of other channel members are updated when the markAsRead()
method is called.
Unread message count
If a member enters a channel and the markAsReadAll()
method is called, the Sendbird server updates the following:
- The unread message count of the individual channel.
- The total unread message count of all the group channels joined by the member.
The server then triggers the onReadStatusUpdated()
method of the channel event handler to notify the change of the read status to all other channel members' devices.
Display past messages for new members
If a new member joins the channel, the method works differently based on the value of the display_past_message
property of your Sendbird application. The display_past_message
property determines whether to display past messages to newly joined members when they enter the channel.
If the property is set to true
, the new member's read receipt is updated to the sent time of the last message in the channel.
Note: This property is also linked to the Chat history option, which can be managed on Sendbird Dashboard under Settings > Chat > Channels > Group channels.