Skip to main content

Global do not disturb (DND)

The Chat SDK lets you configure a global Do Not Disturb (DND) time window and DND level for the current user.

  • You can set a DND window starting at any time of day (HH:MM:SS). The window repeats daily until you update or remove it. For example, to enable all-day DND permanently, set startTime to 00:00:00 and period to 1439.
  • Each user can have only one active DND window. Setting a new window overwrites the previous one.
tip

During a global DND window configured through the SDK:

  • If the client is offline, the Nexconn server will not send push notifications.
  • The global DND window is a user-level setting and has the highest priority. When a global DND window is active, its DND level always takes precedence.

When your app handles local notifications directly, check whether the app has moved to the background and use the SDK's global DND API to decide whether to display a local notification, effectively implementing global DND.

Supported DND levels

When setting a DND time window for the current user, you can choose from the following DND levels:

Enum valueNumeric valueDescription
none0Not set. When not set, the SDK checks the group-level DND settings and other non-user-level settings in order to determine whether to send a push notification.
mentionMessage1Notify only for @ messages, including @specific-user and @everyone messages.
blocked2Block all notifications, including @ messages.

Set DND hours

Set the DND time window for message notifications using NCEngine.setNoDisturbTime().

Dart
await NCEngine.setNoDisturbTime(
NoDisturbTimeParams(
startTime: '22:00:00',
spanMinutes: 480,
level: ChannelNoDisturbLevel.blocked,
),
(error) {
if (error == null) print('DND time set');
},
);

Remove DND hours

Dart
await NCEngine.removeNoDisturbTime((error) {
if (error == null) print('DND time removed');
});

Get DND hours

Dart
await NCEngine.getNoDisturbTime((NCError? error, String? startTime, int? spanMinutes, ChannelNoDisturbLevel? level) {
if (error == null) {
print('DND start: $startTime, duration: $spanMinutes min, level: $level');
}
});