Read receipts
Read receipts show if channel members have viewed a message.
Required setup
Read Receipts requires Unread Message Count. First, set the last read timetoken for each user on a channel.
Stream read receipts
StreamReadReceipts() provides real-time read status for messages on a channel. Use OnReadReceiptEvent to handle updates.
Not available for public chats
Read receipts are disabled in public chats.
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 — enabled by StreamReadReceipts()
2public event Action<ReadReceipt> OnReadReceiptEvent;
3// needs a corresponding event handler
4void EventHandler(ReadReceipt readReceipt)
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. |
readReceiptType: ReadReceiptDefault: n/a | No | Yes | Typed read receipt data containing the user ID and the last read timetoken. |
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
Get read receipts
GetReadReceipts() retrieves a snapshot of read receipts for all members of a channel.
Method signature
This method has the following signature:
1channel.GetReadReceipts(
2 string filter = "",
3 string sort = "",
4 int limit = 0,
5 PNPageObject page = null
6)
Input
| Parameter | Description |
|---|---|
filterType: stringDefault: "" | Expression to filter results. |
sortType: stringDefault: "" | Key-value pair of a property to sort by and a sort direction. |
limitType: intDefault: 0 | Number of results to return. When set to 0, uses the default server value. |
pageType: PNPageObjectDefault: null | Object used for pagination. |
Output
| Type | Description |
|---|---|
Task<ChatOperationResult<List<ReadReceipt>>> | An awaitable Task returning a list of ReadReceipt objects, each containing a UserId and LastReadTimeToken. |
Configure read receipt emission
Control which channel types emit read receipt events by setting EmitReadReceiptEvents in PubnubChatConfig when initializing the Chat SDK. Keys are channel type strings ("public", "group", "direct", or any custom type); values are booleans. By default, read receipts are enabled for group and direct channels and disabled for public channels.
Sample code
1