Set 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.
note
Use the callback to confirm the final result. On this page, ErrorHandler callbacks succeed when error?.isSuccess == true, while getNoDisturbTime() succeeds when error == null.
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 (NoDisturbTimeLevel)
| 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 | NoDisturbTimeLevel | DND level. |
timezone | String? | Optional timezone identifier. |
Code example
Dart
await NCEngine.setNoDisturbTime(
NoDisturbTimeParams(
startTime: '22:00:00',
spanMinutes: 480,
level: NoDisturbTimeLevel.blocked,
),
(error) {
if (error?.isSuccess == true) {
print('DND set');
}
},
);
Remove DND time window
Dart
await NCEngine.removeNoDisturbTime((error) {
if (error?.isSuccess == true) {
print('DND removed');
}
});
Get DND settings
Dart
await NCEngine.getNoDisturbTime((info, error) {
if (error == null) {
print('DND: ${info?.startTime}, ${info?.spanMinutes} min, level: ${info?.level}');
}
});