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, setstartTimeto00:00:00andspanMinutesto1439. - 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)
| Enum | Value | Description |
|---|---|---|
none | 0 | Not set. Falls through to other DND settings. |
mentionMessage | 1 | Only notify for @ messages (both @user and @all). |
blocked | 2 | No notifications, even for @ messages. |
Set DND time window
Method
Dart
static Future<int> setNoDisturbTime(NoDisturbTimeParams params, ErrorHandler handler)
Parameters (NoDisturbTimeParams)
| Parameter | Type | Description |
|---|---|---|
startTime | String | Start time in HH:MM:SS format. |
spanMinutes | int | Duration in minutes (1–1439). Use 1439 for all day. |
level | ChannelNoDisturbLevel | DND level. |
timeZone | String? | 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');
}
});