Skip to main content

Do not disturb by channel type

This guide describes how to set DND levels for a specified channel type.

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 (target 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 channel type 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 type

The SDK allows a user to set DND levels for a specified channel type. Supported types: Direct, Group, and Community channels.

Set DND level for a channel type

Use BaseChannel.setChannelTypeNoDisturbLevel() with a ChannelTypeNoDisturbLevelParams to set the DND level for a channel type. Open channels are not supported because they do not receive message notifications by default.

Parameters (ChannelTypeNoDisturbLevelParams)

ParameterTypeDescription
channelTypeChannelTypeChannel type: ChannelType.DIRECT, ChannelType.GROUP, or ChannelType.COMMUNITY. Open channels are not supported.
levelChannelNoDisturbLevelDND level.
kotlin
// Set DND for all Direct channels
val params = ChannelTypeNoDisturbLevelParams(
channelType = ChannelType.DIRECT,
level = ChannelNoDisturbLevel.MUTED
)

BaseChannel.setChannelTypeNoDisturbLevel(params) { error ->
if (error == null) {
// Successfully set
} else {
// Failed
}
}

// Set DND for all Group channels
val groupParams = ChannelTypeNoDisturbLevelParams(
channelType = ChannelType.GROUP,
level = ChannelNoDisturbLevel.MENTION_USERS
)

BaseChannel.setChannelTypeNoDisturbLevel(groupParams) { error ->
if (error == null) {
// Successfully set
}
}

Remove DND level for a channel type

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

kotlin
val params = ChannelTypeNoDisturbLevelParams(
channelType = ChannelType.DIRECT,
level = ChannelNoDisturbLevel.DEFAULT
)
BaseChannel.setChannelTypeNoDisturbLevel(params) { error ->
if (error == null) {
// DND removed
}
}

Get DND level for a channel type

Use BaseChannel.getChannelTypeNoDisturbLevel() to retrieve the DND level for a specific channel type.

kotlin
BaseChannel.getChannelTypeNoDisturbLevel(ChannelType.DIRECT) { level, error ->
if (error == null && level != null) {
println("DND level for Direct channels: $level")
} else {
// Failed
}
}

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.