Skip to main content

Sync read status across devices

In a multi-device scenario, read and unread status is stored locally on each device. When a user reads messages on one device, you can sync that state to the user's other devices by clearing the unread count.

tip

Clearing the unread count on the current device sends a sync notification to other devices logged in with the same account.

Clear unread count (syncs to other devices)

Call clearUnreadCount(completion:) on a channel instance. This resets the local unread counter and notifies the user's other devices of the read state:

swift
import NexconnChatSDK
guard let channel = DirectChannel(channelId: "targetUserId") else { return }
channel.clearUnreadCount { isCleared, error in
if isCleared {
print("Read status cleared and synced.")
}
}
swift
import NexconnChatSDK
// Group channel example
guard let group = GroupChannel(channelId: "groupId") else { return }
group.clearUnreadCount { isCleared, error in
if isCleared {
print("Group unread count cleared.")
}
}