Sync read status across devices
When a user reads messages on one device, the read status can be synchronized to all other devices. This prevents unread badges from appearing on channels that the user has already read on another device.
How it works
When a user opens a channel and reads messages on Device A, the read timestamp is sent to the server. Other devices (B, C, etc.) receive the updated read status and adjust their local unread counts accordingly.
Send a read status sync request
Mark messages as read and sync the status:
TypeScript
import { DirectChannel } from '@nexconn/chat';
const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.clearUnreadCount();
if (code === 0) {
console.log('Read status synced');
}
Listen for read status sync events
When another device clears the unread count for a channel, your current device receives a notification:
TypeScript
import { NCEngine, ChannelHandler } from '@nexconn/chat';
NCEngine.addChannelHandler('sync-handler', new ChannelHandler({
onChannelStatusSyncCompleted({ code }) {
// Called when channel status data (including read status) finishes syncing
console.log('Channel status sync completed. Code:', code);
},
onCommunityChannelsSyncCompleted() {
// Called when community channel sync completes
console.log('Community channels sync completed');
},
}));
info
Multi-device read status sync requires the multi-device online feature to be enabled. See Multi-device online.