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 signature

    1// event on the Channel entity — enabled by StreamReadReceipts()
    2public event Action<ReadReceipt> OnReadReceiptEvent;
    3// needs a corresponding event handler
    4void EventHandler(ReadReceipt readReceipt)

Input​

stream#
Type: bool
Default: no default
Whether to start (true) or stop (false) listening to read receipt events on the channel.
Required in StreamReadReceipts()
Yes
Required in OnReadReceiptEvent
n/a
readReceipt#
Type: ReadReceipt
Default: no default
Typed read receipt data containing the user ID and the last read timetoken.
Required in StreamReadReceipts()
No
Required in OnReadReceiptEvent
Yes

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​

filter#
Type: string
Default: ""
Expression to filter results.
sort#
Type: string
Default: ""
Key-value pair of a property to sort by and a sort direction.
limit#
Type: int
Default: 0
Number of results to return. When set to 0, uses the default server value.
page#
Type: PNPageObject
Default: null
Object used for pagination.

Output​

TypeDescription
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

Was this page useful?

Last updated on