Read receipts
Read receipts indicate if other channel members have received and viewed a message.
Required setup
Read Receipts feature is tightly coupled with the Unread Message Count feature. To receive message read receipts, you must know which message was last read by which user on a given channel. That's why, to implement the Read Receipts feature, you must first set the timetoken of the last message a user read on a given channel. Based on that, Unity Chat SDK will map a user's last read message to a given message timetoken and let you show this mapping result in your chat app as read or unread.
Get read receipts
Get a read confirmation status for messages you published on a channel.
Use the StreamReadReceipts() method to enable or disable read receipt event streaming on a channel, and the OnReadReceiptEvent event to handle read receipt updates.
Not available for public chats
Read receipts are disabled in public chats. If you try implementing this feature in a public channel type, you'll get the Read receipts are not supported in Public chats error.
Method naming
Earlier versions used SetListeningForReadReceiptsEvents() to enable streaming. This method has been superseded by StreamReadReceipts(), though it remains available for backward compatibility.
Method signature
These methods take the following parameters:
-
StreamReadReceipts()1channel.StreamReadReceipts(bool stream) -
OnReadReceiptEvent- Event signature1// event on the Channel entity
2public event Action<Dictionary<string, List<string>>> OnReadReceiptEvent;
3// needs a corresponding event handler
4void EventHandler(Dictionary<string, List<string>> readEvent)
Input
| Parameter | Required in StreamReadReceipts() | Required in OnReadReceiptEvent | Description |
|---|---|---|---|
streamType: boolDefault: n/a | Yes | n/a | Whether to start (true) or stop (false) listening to read receipt events on the channel. |
readEventType: Dictionary<string, List<string>>Default: n/a | No | Yes | A dictionary where keys are channel IDs and values are lists of user IDs who read messages on those channels. |
Output
These methods don't return a value. Read receipt updates are delivered through the OnReadReceiptEvent event handler.
Sample code
Receive updates for read receipts on the support channel.
1