Skip to main content

Do not disturb by target ID

This guide describes how to set DND levels for a specific channel (channelId).

tip

The Chat SDK supports multi-dimensional, multi-level DND settings.

  • You can configure DND at the App Key level, sub-channel level (Community channels only), and user level. When the server determines whether to trigger a push notification, the priority order is: User-level > Community sub-channel default (Community channels only) > Community channel default (Community channels only) > App Key-level.
  • Within user-level settings, multiple dimensions exist. The priority order is: Global DND > DND by sub-channel > DND by channel (channel ID) > DND by channel type. See DND overview.

Supported DND levels

DND levels control notifications based on @mention message types. The following levels are available for per-channel DND:

Enum valueValueDescription
ChannelNoDisturbLevel.ALL-1Notify for all messages.
ChannelNoDisturbLevel.DEFAULT0Not set. This is the initial default state.

Note: When not set, if neither the Community channel nor its sub-channels have DND configured, the default behavior is to notify for all messages.
ChannelNoDisturbLevel.MENTION1Only notify for @mention messages, including @specific user and @all members.
ChannelNoDisturbLevel.MENTION_USERS2Only notify for @specific user messages. Only the mentioned user receives the notification.

For example, if "@User_A" is sent, User_A receives a notification. @all does not trigger a notification.
ChannelNoDisturbLevel.MENTION_ALL4Only notify for @all members messages.
ChannelNoDisturbLevel.MUTED5No notifications at all, even for @mention messages.

Manage DND by channel

Set DND levels for a specific channel (channelId) for the current user (userId). Supported types: Direct, Group, and Community channels.

Set DND level for a channel

Use channel.setNoDisturbLevel() to set the DND level for a specific channel for the current user.

Parameters

ParameterTypeDescription
levelChannelNoDisturbLevel
  • ALL: Notify for all messages
  • DEFAULT: Not set (falls back to Group or App Key-level default; if none set, notifies for all messages)
  • MENTION: Only notify for @mention messages
  • MENTION_USERS: Only notify for @specific user

    For example, @User_A triggers a notification for User_A; @all does not.

  • MENTION_ALL: Only notify for @all members.
  • MUTED: No notifications
handlerErrorHandler?Callback. error is null on success.
kotlin
// Get channel instance
val channel = DirectChannel("userId123")
// Or: val channel = GroupChannel("groupId456")
// Or: val channel = CommunityChannel("communityId789")

// Set to notify only for @mentions of me
channel.setNoDisturbLevel(ChannelNoDisturbLevel.MENTION_USERS) { error ->
if (error == null) {
// Successfully set
} else {
// Failed
}
}

// Block all notifications
channel.setNoDisturbLevel(ChannelNoDisturbLevel.MUTED) { error ->
if (error == null) {
// Successfully blocked
}
}
tip

Community channel type: If you enabled Community channels before 2022.09.01, this API only sets the DND level for messages not belonging to any sub-channel by default. To change this behavior, submit a support ticket.

Open channel type: Not supported, because Open channels do not support push notification reminders.

Remove DND level for a channel

To remove DND for a channel, call the set API and pass ChannelNoDisturbLevel.DEFAULT as the level parameter.

kotlin
channel.setNoDisturbLevel(ChannelNoDisturbLevel.DEFAULT) { error ->
if (error == null) {
// DND removed
}
}

Get DND level for a channel

Read the channelNoDisturbLevel property from the channel object to get the cached value.

kotlin
// Read cached value
val channel = DirectChannel("userId123")
val cachedLevel = channel.channelNoDisturbLevel

Multi-device sync

The 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. See Multi-device channel status sync.

Use NCEngine.addChannelHandler() to listen for channel DND level changes:

kotlin
NCEngine.addChannelHandler("CHANNEL_STATUS", object : ChannelHandler {
override fun onChannelNoDisturbLevelSync(event: ChannelNoDisturbLevelSyncEvent) {
println("Channel ${event.channelIdentifier.channelId} DND level changed to: ${event.level}")
}
})