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

streamReadReceipts() lets you get a read confirmation status for messages you published on a channel.

When called, the method fetches the read status of the members, listens for new messages, and updates the read status accordingly. The read status is then passed as an event of the receipt type to a callback function for further processing or display.

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 signature

channel.streamReadReceipts(callback: (receipts: {
[key: string]: string[];
}) => unknown): Promise<() => void>

Input

ParameterTypeRequiredDefaultDescription
callbackn/aYesn/aCallback function passed as a parameter. It defines the custom behavior to be executed when receiving a read confirmation status on the joined channel.
 → receiptsobjectYesn/aThe received object maps message timetokens to users who last read these messages, like {147289397461273: ["user1", "user2"], 147289399472194: ["user3"]}.

Output

TypeDescription
voidMethod returns a promise that resolves to an unsubscriber.

Basic Usage

Receive updates for read receipts on the support channel.

// reference the "support" channel
const channel = await chat.getChannel("support")

const stopReceipts = await channel.streamReadReceipts((receipts) => {
// callback to handle current receipts data
})

// after some time...
stopReceipts()
Last updated on