Skip to main content

Multi-device channel status sync

The Chat SDK provides a channel status (pin and DND) sync mechanism. Set a channel status sync listener to receive real-time updates when the channel status changes on another device.

Listener

Use NCEngine.addChannelHandler() to register a ChannelHandler. The ChannelHandler provides individual callbacks for pin and DND status changes synced from other devices:

CallbackParametersDescription
onChannelPinnedSyncevent: ChannelPinnedSyncEventFires when a channel's pin status changes on another device. Use event.channelIdentifier and event.isPinned.
onChannelNoDisturbLevelSyncevent: ChannelNoDisturbLevelSyncEventFires when a channel's DND level changes on another device. Use event.channelIdentifier and event.level.
onChannelStatusSyncCompletedevent: ChannelStatusSyncCompletedEventFires when the initial channel status sync completes after connection. Use event.error.

Register the listener

Register a channel status sync listener for pin and DND changes across devices.

kotlin
NCEngine.addChannelHandler("CHANNEL_STATUS_SYNC", object : ChannelHandler {
override fun onChannelPinnedSync(event: ChannelPinnedSyncEvent) {
val channelId = event.channelIdentifier.channelId
Log.d("Sync", "Channel $channelId pinned: ${event.isPinned}")
// Update UI accordingly
}

override fun onChannelNoDisturbLevelSync(event: ChannelNoDisturbLevelSyncEvent) {
val channelId = event.channelIdentifier.channelId
Log.d("Sync", "Channel $channelId DND level: ${event.level}")
// Update UI accordingly
}

override fun onChannelStatusSyncCompleted(event: ChannelStatusSyncCompletedEvent) {
if (event.error == null) {
// Initial sync complete after connection
}
}
})

Remove the listener

kotlin
NCEngine.removeChannelHandler("CHANNEL_STATUS_SYNC")