Skip to main content

Global do not disturb

Set a global do not disturb (DND) time window and level for the current user.

  • Define a DND window starting at any time (HH:MM:SS). The window repeats daily until changed or removed. For all-day DND, set startTime to 00:00:00 and spanMinutes to 1439.
  • Each user supports only one DND window. Setting a new window replaces the previous one.
tip

During the global DND window:

  • The server does not send push notifications to offline devices.
  • Global DND is a user-level setting with the highest priority, overriding all other DND settings.

Supported DND levels (ChannelNoDisturbLevel)

EnumValueDescription
none0Not set. Falls through to other DND settings.
mentionMessage1Only notify for @ messages (both @user and @all).
blocked2No notifications, even for @ messages.

Set DND time window

Method

Dart
static Future<int> setNoDisturbTime(NoDisturbTimeParams params, ErrorHandler handler)

Parameters (NoDisturbTimeParams)

ParameterTypeDescription
startTimeStringStart time in HH:MM:SS format.
spanMinutesintDuration in minutes (1–1439). Use 1439 for all day.
levelChannelNoDisturbLevelDND level.
timeZoneString?Optional timezone identifier.

Code example

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

Remove DND time window

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

Get DND settings

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