Set global do not disturb
The client can configure a silent notification time window to implement global do not disturb functionality. This feature sets a recurring daily time window that remains effective until modified or removed.
Chat UI doesn't provide direct UI for global do not disturb settings. You need to use methods from the Chat SDK. See the global do not disturb capabilities in NCEngine.
For Chat UI integrations, we recommend using the NCEngine interface in Chat SDK that allows simultaneous configuration of both the time window and "do not disturb level".
During the global do not disturb period configured through the SDK:
- When the client runs in background, new messages in channels won't trigger notification alerts, though message content will still be received
- When the client is offline, no remote notifications will be received
- Exception: @mentions are high-priority messages that bypass global do not disturb and always trigger notifications
Set global do not disturb
NCEngine provides the setNoDisturbTimeWithParams:completion: method to configure both the time window and do not disturb level. Create NCNoDisturbTimeParams with initWithStartTime:spanMinutes:.
- Swift
- Objective-C
let params = NCNoDisturbTimeParams(startTime: "22:00:00", spanMinutes: 480)
params.level = .muted
NCEngine.setNoDisturbTime(with: params) { error in }
NCNoDisturbTimeParams *params = [[NCNoDisturbTimeParams alloc] initWithStartTime:@"22:00:00" spanMinutes:480];
params.level = NCNoDisturbTimeLevelMuted;
[NCEngine setNoDisturbTimeWithParams:params completion:^(NCError * _Nullable error) {}];
Get global do not disturb settings
The client can actively retrieve the latest global do not disturb configuration.
- Swift
- Objective-C
NCEngine.getNoDisturbTime { info, error in }
[NCEngine getNoDisturbTimeWithCompletion:^(NCNoDisturbTimeInfo * _Nullable info, NCError * _Nullable error) {}];
Remove global do not disturb
- Swift
- Objective-C
NCEngine.removeNoDisturbTime { error in }
[NCEngine removeNoDisturbTimeWithCompletion:^(NCError * _Nullable error) {}];