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.
Get read receipts
streamReadReceipts() provides read status for messages on a channel. The method fetches member read status, listens for updates, and passes receipt events to your callback.
Not available for public chats
Read receipts are disabled in public chats.
Method signature
1channel.streamReadReceipts(callback: (receipts: {
2 [key: string]: string[];
3}) => unknown): Promise<() => void>
Input
* required
| Parameter | Description |
|---|---|
callback *Type: n/a Default: n/a | Callback function passed as a parameter. It defines the custom behavior to be executed when receiving a read confirmation status on the joined channel. |
→ receipts *Type: objectDefault: n/a | The received object maps message timetokens to users who last read these messages, like {147289397461273: ["user1", "user2"], 147289399472194: ["user3"]}. |
Output
| Type | Description |
|---|---|
void | Method returns a promise that resolves to an unsubscriber. |
Sample code
Receive updates for read receipts on the support channel.
1// reference the "support" channel
2const channel = await chat.getChannel("support")
3
4const stopReceipts = await channel.streamReadReceipts((receipts) => {
5 // callback to handle current receipts data
6})
7
8// after some time...
9stopReceipts()