Chat / Flutter
Current version: v3
Chat Flutter v3
Chat Flutter
Chat
Flutter
Home
/
Chat
/
Flutter
/
Message

Mark messages as read

To keep the most up-to-date and accurate read status of messages for all group channel members, the markAsRead() method should be called every time a member reads messages by entering the channel from a channel list or switching the chat view from the background to the foreground.

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.

If a member opens a channel and the markAsReadAll() method is called, the Sendbird server updates both the unread message count of the individual channel and the total unread message count of all the group channels joined by the member. The server then triggers the onReadReceiptUpdated() method of the channel event handler to notify the change of the read status to all other channel members' devices.

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. 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.

class MyClass with ChannelEventHandler {
    // Add this class through sendbird.addChannelEventHandler(UNIQUE_HANDLER_ID, this).
    // Or remove it through sendbird.removeChannelEventHandler(UNIQUE_HANDLER_ID) when it's no longer needed.

    @override
    void onReadReceiptUpdated(GroupChannel channel) {
        // Read receipt is updated.
    }
}

Note: The display_past_message property determines whether to display past messages to newly joined members when they enter the channel. This property is also linked to the Chat history option, which can be managed on Sendbird Dashboard under Settings > Chat > Channels > Group channels.