# Set DND mode (/en/realtime-media/im/build/notifications-and-event-handling/offline-push/set-dnd-mode/web)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

To optimize the user experience when dealing with a large number of push notifications, Chat SDK provides fine-grained settings for push notifications and DND mode at the app and conversation levels.

    **Push notifications**

    | Setting | Description                                                                                                                                                                                                                                                                                                                                 | App | One-to-one and group chats |
    | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-- | :------------------------- |
    | `ALL`   | Receive push notifications for all offline messages.                                                                                                                                                                                                                                                                                        | ✓   | ✓                          |
    | `AT`    | Only receive push notifications for mentions.  This parameter is recommended for group chats. If a user wants to mention one or more users, they need to pass `"em_at_list": [ "user1", "user2" ... ]` to the `ext` field when creating a message; if they want to mention everyone, they need to pass `"em_at_list": "all"` to this field. | ✓   | ✓                          |
    | `NONE`  | Do not receive push notifications for offline messages.                                                                                                                                                                                                                                                                                     | ✓   | ✓                          |

    The push notification setting at the conversation level takes precedence over the setting at the app level. For conversations where push notifications are not configured, the app setting is used by default.

    For example, suppose the push notifications are set to `AT` for the app and to `ALL` for a given conversation. The user will receive all push notifications from that conversation, but for all other conversations, they will only receive push notifications for mentions.

    **Do Not Disturb**

    After you have completed SDK initialization and successfully logged into the app, you can enable offline push for the app and various types of conversations, as well as turning off push by setting the DND mode.

    You can specify the DND time period and duration at the app level, and Chat will not send offline push notifications during these two periods. If both the DND time and DND duration are set, the DND mode will take effect for the sum of the two.

    The following table describes the DND time settings:

    | Setting               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | App | One-to-one and group chats |
    | :-------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-- | :------------------------- |
    | `startTime & endTime` | The time period for turning on the DND mode, in the `H:MH:M` format, using the 24-hour system and accurate to the minute. For example, `8:30`-`10:0`, the range of hours and minutes in the start time and end time is `[0,23]` and `[0,59]`, respectively. The DND mode is set in the following way: After the start time and end time are set, the DND mode is triggered every day. For example, if the time period is set to `8:0`-`10:0`, the DND mode is effective from 8:00 to 10:00 every day. If you set the start time to `8:0` and the end time to `12:0` at 11:00, the DND mode is effective from 11:00 to 12:00 on the same day, and from 8:00 to 12:00 every day thereafter. If the start time and end time are the same, the DND mode is effective all day. However, if it is set to `0:0`-`0:0`, the DND mode is turned off. If the end time is earlier than the start time, the DND mode takes effect from the start time of each day to the end time of the next day. For example, if the start time is `10:0` and the end time is `8:0`, the DND mode takes effect from 10:00 on the same day to 8:00 on the next day. Currently, the DND mode is only supported in a specified time period each day. Multiple DND time periods are not supported. The new setting will override the previous setting. If both this parameter and `duration` are set, the DND mode takes effect in both time periods on the same day. For example, if `startTime & endTime` is set to `8:0`-`10:0` at 8:00 AM and `duration` is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12:00 on the same day and from 8:00-10:0 every day thereafter. | ✓   | ✗                          |
    | `duration`            | The duration of the DND mode, in minutes. The value range of the DND duration is `[0,10080]`, `0` means that the parameter is invalid, and `10080` means that the DND mode lasts for 7 days. Unlike the setting of the DND time period, which takes effect every day, this parameter is valid once. It takes effect immediately after setting. For example, if the app-level `duration` is set to 240 minutes (4 hours) at 8:00 am, the app will be in DND mode from 8:00 to 12:00 on the same day.  - If both this parameter and `startTime & endTime` are set, the DND mode will take effect in both time periods on the same day. For example, if the app-level `startTime & endTime` is set to 8:00-10:00 at 8:00 AM, and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00 to 12:00 and from 8:00 to 10:00 every day thereafter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | ✓   | ✓                          |

    If you need to push messages to specific users during the DND period or effective time, set [Force push](./configure-push-notifications).

    For the app and all conversations in the app, the DND mode setting takes precedence over the push notification setting. For example, suppose you specify a DND time period at the app level and set push notifications for a specified conversation to `ALL` . The app enters the DND mode during the specified time period, and you will not receive any push notifications.

    Alternatively, suppose a conversation is assigned a quiet time period, and the app does not have any quiet settings and its push notifications are set to `ALL`. During the specified quiet time, you will not receive any push notifications from this conversation, while push notifications from all other conversations remain unchanged.

    ### Set up push notifications for the app [#set-up-push-notifications-for-the-app-2]

    Call `setSilentModeForAll` to set app-level push notifications. Configure the push notification and DND settings by specifying the `paramType` field, as shown in the following code example:

    ```javascript
    /**
      options // Push notification configuration options.
      options: {
        paramType: 0, // Push notification method.
        remindType: 'ALL' // Can be set to `ALL`, `AT` or `NONE`.
      }
      options: {
        paramType: 1, // Do not disturb duration.
        duration: 7200000 // Do not disturb duration, in milliseconds.
      }
      options: {
        paramType: 2, // Do not disturb time period.
        startTime: {
          hours: 8, // The number of hours in the start time of the do not disturb period.
          minutes: 0 // The number of minutes in the start time of the do not disturb period.
        }，
        endTime: {
          hours: 12, // The number of hours in the end time of the do not disturb period.
          minutes: 0 // The number of minutes in the end time of the do not disturb period.
        }
      }
    */
    const params = {
      options: {
        paramType: 0,
        remindType: "ALL",
      },
    };
    chatClient.setSilentModeForAll(params);
    ```

    ### Get the push notification settings of the app [#get-the-push-notification-settings-of-the-app-2]

    Call `getSilentModeForAll` to get the push notification settings of the app. The sample code is as follows:

    ```javascript
    chatClient.getSilentModeForAll();
    ```

    ### Set push notifications for a single conversation [#set-push-notifications-for-a-single-conversation-2]

    Call `setSilentModeForConversation` to configure the push notification settings for a specified conversation. The sample code is as follows:

    ```javascript
    /**
      const params = {
        conversationId: 'conversationId', // Conversation ID: For one-to-one chat, it is the other party's user ID; for group chat, it is the group ID.
        type: 'singleChat', // Conversation type: singleChat (one-to-one chat), groupChat (group chat).
        options: {
          paramType: 0, // Push notification settings.
          remindType: 'ALL' // Can be set to `ALL`, `AT` or `NONE`.
        }
      }

      const params = {
        conversationId: 'conversationId',
        type: 'groupChat',
        options: {
          paramType: 1, // Do not disturb duration.
          duration: 7200000 // Do not disturb duration, in milliseconds.
        }
      }

      const params = {
        conversationId: 'conversationId',
        type: 'chatRoom',
        options: {
          paramType: 2, // Do not disturb time period.
          startTime: {
            hours: 8, // The number of hours in the start time of the do not disturb period.
            minutes: 0 // The number of minutes in the start time of the do not disturb period.
          }，
          endTime: {
            hours: 12, // The number of hours in the end time of the do not disturb period.
            minutes: 0 // The number of minutes in the end time of the do not disturb period.
          }
        }
      }
    */
    const params = {
      conversationId: "conversationId",
      type: "groupChat",
      options: {
        paramType: 0,
        remindType: "ALL",
      },
    };
    chatClient.setSilentModeForConversation(params);
    ```

    ### Get push notification settings for a single conversation [#get-push-notification-settings-for-a-single-conversation-2]

    Call `getSilentModeForConversation` to get the push notification settings for a single conversation. The sample code is as follows:

    ```javascript
    const params = {
      conversationId: " conversationId ", // Conversation ID: For one-to-one chat, it is the other party's user ID; for group chat, it is the group ID.
      type: " singleChat ", // Conversation type: singleChat is a one-to-one chat, groupChat is a group chat.
    };
    chatClient.getSilentModeForConversation(params);
    ```

    ### Get push notification settings for multiple conversations [#get-push-notification-settings-for-multiple-conversations-2]

    1. You can get push notification settings for up to 20 conversations at a time.
    2. If the conversation uses app settings or its push notification settings have expired, the returned dictionary does not contain this conversation.

    Call `getSilentModeForConversations` to get the push notification settings for multiple conversations. The sample code is as follows :

    ```javascript
    const params = {
      conversationList: [
        {
          id: " conversationId ", // Conversation ID: For one-to-one chat, it is the other party's user ID; for group chat, it is the group ID.
          type: " singleChat ", // Conversation type: singleChat is a one-to-one chat, groupChat is a group chat.
        },
        {
          id: "conversationId",
          type: "groupChat",
        },
      ],
    };
    chatClient.getSilentModeForConversations(params);
    ```

    ### Clear push notification settings for a single conversation [#clear-push-notification-settings-for-a-single-conversation-2]

    Call `clearRemindTypeForConversation` to clear the push notification type settings for a specified conversation. After clearing, this conversation will use the app's settings by default. The sample code is as follows:

    ```javascript
    const params = {
      conversationId: " conversationId ", // Conversation ID: For one-to-one chat, it is the other party's user ID; for group chat, it is the group ID.
      type: " groupChat ", // Conversation type: singleChat is a one-to-one chat, groupChat is a group chat.
    };
    chatClient.clearRemindTypeForConversation(params);
    ```

    
  
      
  
      
  
      
  
      
  
