Skip to main content

Global do not disturb

Set a global do not disturb (DND) window for the current user. During the window, the server does not send push notifications for missed messages.

  • The window is defined by a start time (HH:mm:ss) and a duration in minutes. It repeats daily until changed.
  • To enable all-day DND permanently, set startTime to 00:00:00 and spanMinutes to 1439.
  • Each user can have only one active window. Setting a new one replaces the previous.
tip

Global DND has the highest priority. When active, it overrides DND settings by channel and by channel type.

If the app is running in the background, use the DND level you set here to decide whether to display local notifications.

Set the DND window

Create a NoDisturbTimeParams object and call NCEngine.setNoDisturbTime(params:completion:):

swift
import Foundation
import NexconnChatSDK

let params = NoDisturbTimeParams(startTime: "00:00:00", spanMinutes: 1439)
params.level = .muted
params.timezone = TimeZone.current.identifier

NCEngine.setNoDisturbTime(params: params) { error in
if let error {
print("Failed: \(error.localizedDescription)")
return
}

print("DND window set.")
}

NCNoDisturbTimeParams

ParameterTypeRequiredDescription
startTimeNSStringYesStart time in HH:mm:ss format (for example, 01:30:00)
spanMinutesint32_tYesDuration in minutes. Range: 1 to 1439.
levelNCNoDisturbTimeLevelNoNotification level during the window. Default: .default.
timezoneNSStringNoTimezone name, for example Asia/Shanghai. Uses the server default when nil.

NCNoDisturbTimeLevel

Enum valueNumeric valueDescription
NCNoDisturbTimeLevelDefault0Not set. Falls through to other DND settings.
NCNoDisturbTimeLevelMention1Notify only for @mention messages (@user and @everyone).
NCNoDisturbTimeLevelMuted5Suppress all notifications, including mentions.

Remove the DND window

To remove the DND window, set level to .default for the full day:

swift
import NexconnChatSDK

let params = NoDisturbTimeParams(startTime: "00:00:00", spanMinutes: 1439)
params.level = .default

NCEngine.setNoDisturbTime(params: params) { error in
if error == nil {
print("DND window cleared.")
}
}