Read receipts
Send and receive read receipts to inform the sender that their message has been read.
How it works
- The sender sends a message.
- The recipient reads the message and sends a read receipt.
- The sender receives the read receipt notification via
MessageHandler.onMessageReceiptResponse.
Send a read receipt
After the user reads messages, send a read receipt by calling sendReadReceiptResponse on the channel, passing the message IDs:
TypeScript
import { DirectChannel } from '@nexconn/chat';
const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.sendReadReceiptResponse(['<message-uid-1>', '<message-uid-2>']);
if (code === 0) {
console.log('Read receipt sent');
}
Parameters
| Parameter | Type | Description |
|---|---|---|
messageIds | string[] | Array of message unique IDs that were read |
Listen for read receipt responses
Register a MessageHandler to receive read receipt notifications:
TypeScript
import { NCEngine, MessageHandler } from '@nexconn/chat';
NCEngine.addMessageHandler('receipt-handler', new MessageHandler({
onMessageReceiptResponse({ responses }) {
console.log('Read receipts received:', responses);
},
}));
Query read receipt users (group channels)
In group channels, use BaseChannel.createMessagesReadReceiptUsersQuery() to query which members have read a specific message:
TypeScript
import { BaseChannel, MessageReadReceiptStatus, GroupChannel } from '@nexconn/chat';
const channel = new GroupChannel('<group-id>');
const query = BaseChannel.createMessagesReadReceiptUsersQuery({
channelIdentifier: channel.identifier,
messageId: '<message-uid>',
pageSize: 20,
status: MessageReadReceiptStatus.READ,
});
const { code, data } = await query.loadNextPage();
if (code === 0) {
console.log('Users who read the message:', data);
}
info
- Read receipts are a paid feature. Enable them in the Console.