Skip to main content

Set Global Do Not Disturb

The IMKit SDK supports configuring notification silent periods to achieve global Do Not Disturb effects.

  • This interface sets a Do Not Disturb time window starting from any specified time (HH:MM:SS). Unless reconfigured or removed, the set time window will repeat daily. For example, to enable permanent all-day Do Not Disturb, set startTime as 00:00:00 and period as 1439.
  • Each user can only configure one time window. Repeated configurations will overwrite previous settings.
tip

Starting from version 5.2.2, IMKit-integrated clients are recommended to use the IMLib's ChannelClient class, which supports simultaneous configuration of "Do Not Disturb Level" for global Do Not Disturb. For details, refer to the IMLib documentation Global Do Not Disturb.

During the configured Global Do Not Disturb period:

  • If the client runs in the background, new messages in conversations will not trigger notifications, though message content remains accessible.
  • Offline clients will not receive vendor push notifications.
  • Exception: @mentions are high-priority messages and will always trigger notifications, unaffected by Global Do Not Disturb.

Configure Global Do Not Disturb Period (< 5.2.2)

Set a Global Do Not Disturb period to mute all notifications, including local and remote push notifications.

Interface

RongNotificationManager.getInstance().setNotificationQuietHours(startTime, spanMinutes, callback)

Parameters

ParameterTypeDescription
startTimeStringStart time in HH:MM:SS format (e.g., 01:31:17). Precision: seconds.
spanMinutesintDo Not Disturb window duration in minutes. Valid range: [1-1439].
callbackRongIMClient.OperationCallbackOperation callback.

Retrieve Global Do Not Disturb Period (< 5.2.2)

Fetch the currently configured silent period for the application.

Interface

RongNotificationManager.getInstance().getNotificationQuietHours(callback);

Parameters

ParameterTypeDescription
callbackGetNotificationQuietHoursCallbackCallback to retrieve Global Do Not Disturb settings.

GetNotificationQuietHoursCallback provides two callback methods:

  • Success callback:

    /**
    * Callback when the silent period is successfully retrieved.
    *
    * @param startTime Start time in `HH:MM:SS` format.
    * @param spanMinutes Duration in minutes (0 < spanMinutes < 1440).
    */
    void onSuccess(String startTime, int spanMinutes);
  • Error callback:

    /**
    * Callback when retrieval fails.
    *
    * @param errorCode Error code.
    */
    void onError(ErrorCode errorCode);

Disable Global Do Not Disturb (< 5.2.2)

Remove the configured silent period via removeNotificationQuietHours. Once disabled, local and push notifications will resume normally.

RongNotificationManager.getInstance().removeNotificationQuietHours(callback);