For AI agents: see the complete documentation index at /llms.txt.
Set DND mode
Updated
Set push notifications to DND
To optimize the user experience when dealing with a large number of push notifications, Chat SDK provides fine-grained settings for push notifications and do not disturb mode at the app and conversation levels.
Push notification settings
| Parameter | Description | App | One-to-one and group chats |
|---|---|---|---|
ALL | Receive push notifications for all offline messages. | ✓ | ✓ |
MENTION_ONLY | Receive push notifications only for mentions. This parameter is recommended for group chats. To mention one or more users, pass "em_at_list": [ "user1", "user2" ... ] to the ext field when creating a message. To mention all, 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 the push notification setting is not configured, the app setting is used by default.
For example, suppose the push notifications for the app are set to MENTION_ONLY and the push notifications for a given conversation are set to ALL. A user will receive all push notifications from that conversation, but for all other conversations, they will only receive push notifications for messages that mention them.
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 |
|---|---|---|---|
SILENT_MODE_INTERVAL | 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 to 10 every day. If you set the start time to 8:0 and the end time to 12:0 at 11, the DND mode is effective from 11 to 12 on the same day, and from 8 to 12 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 will be turned off. If the end time is earlier than the start time, the DND mode will take 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 will take effect from 10 on that day to 8 on the next day. The DND mode can only be enabled during 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 SILENT_MODE_DURATION are set, the DND mode will be in effect during both time periods on the day. For example, if SILENT_MODE_INTERVAL is set to 8:0-10:0 and SILENT_MODE_DURATION is set to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8:00-12 on that day and from 8:00-10 every day thereafter. | ✓ | ✗ |
SILENT_MODE_DURATION | The DND duration, in minutes. The value range of the DND duration is [0,10080], where 0 means the parameter is invalid and 10080 means 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 you set the app-level SILENT_MODE_DURATION to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8 to 12 on the same day. If both this parameter and SILENT_MODE_INTERVAL are set, the DND mode will be effective during both time periods on the same day. For example, if the app-level SILENT_MODE_INTERVAL is set to 8:00-10 at 8 am and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12 now and from 8:00-10 every day thereafter. | ✓ | ✓ |
If you need to push messages to specific users during the DND period or effective time, set Force push.
For the app and all conversations in the app, the DND setting takes precedence over the push notification setting. For example, suppose a user specifies a DND time period at the app level and sets push notifications to ALL. The app enters the DND mode during the specified time period, and the user will not receive any push notifications.
Alternatively, suppose a conversation is assigned a DND time period. The app does not have any DND settings and its push notifications are set to ALL. During the specified DND time period, the user will not receive any push notifications from this conversation, while push notifications from all other conversations will remain unchanged.
Set up push notifications for the app
Call setSilentModeForAll to set app-level push notifications. Set push notifications and DND mode by specifying the SilentModeParam field, as shown in the following example:
// Set push notification mode to `MENTION_ONLY`.
SilentModeParam param = new SilentModeParam ( SilentModeParam . SilentModeParamType . REMIND_TYPE )
.setRemindType(PushManager.PushRemindType.MENTION_ONLY);
// Set the offline push do not disturb timer to 15 minutes.
SilentModeParam param = new SilentModeParam ( SilentModeParam . SilentModeParamType . SILENT_MODE_DURATION )
.setSilentModeDuration(15);
// Set the do not disturb time period for offline push to 8:30 to 15:00.
SilentModeParam param = new SilentModeParam ( SilentModeParam . SilentModeParamType . SILENT_MODE_INTERVAL )
.setSilentModeInterval(new SilentModeTime(8, 30), new SilentModeTime(15, 0));
// Set up offline push notifications for the app.
ChatClient.getInstance().pushManager().setSilentModeForAll(param, new ValueCallBack(){});Get the push notification settings of the app
Call getSilentModeForAll to get the app-level push notification settings, as shown in the following example:
ChatClient.getInstance().pushManager().getSilentModeForAll(new ValueCallBack(){
@Override
public void onSuccess(SilentModeResult result) {
// Get the push notification method settings of the app.
PushManager.PushRemindType remindType = result.getRemindType();
// Get the Unix timestamp of the app's offline push Do Not Disturb expiration.
long timestamp = result.getExpireTimestamp();
// Get the start time of the app's offline push do not disturb time period.
SilentModeTime startTime = result.getSilentModeStartTime();
startTime . getHour(); // The hour in the start time of the do not disturb time period.
startTime . getMinute(); // The number of minutes in the start time of the do not disturb time period.
// Get the end time of the app's offline push do not disturb time period.
SilentModeTime endTime = result.getSilentModeEndTime();
endTime . getHour(); // The number of hours in the end time of the do not disturb period.
endTime . getMinute(); // The number of minutes in the end time of the do not disturb time period.
}
@Override
public void onError(int error, String errorMsg) {}
});Set push notifications for a single conversation
Call setSilentModeForConversation to set push notifications for a specified conversation. Configure push notifications and the DND mode by specifying the SilentModeParam field, as shown in the following example:
// Set push notification mode to `MENTION_ONLY`.
SilentModeParam param = new SilentModeParam ( SilentModeParam . SilentModeParamType . REMIND_TYPE )
.setRemindType(PushManager.PushRemindType.MENTION_ONLY);
// Set the offline push do not disturb timer to 15 minutes.
SilentModeParam param = new SilentModeParam ( SilentModeParam . SilentModeParamType . SILENT_MODE_DURATION )
.setSilentDuration(15);
// Set the offline push do not disturb mode for the conversation. Currently, it does not support setting the do not disturb time period for the conversation.
ChatClient.getInstance().pushManager().setSilentModeForConversation(conversationId, conversationType, param, new ValueCallBack(){});Get push notification settings for a single conversation
Call getSilentModeForConversation to get the push notification settings for a specified conversation, as shown in the following code example:
ChatClient.getInstance().pushManager().getSilentModeForConversation(conversationId, conversationType, new ValueCallBack(){
@Override
public void onSuccess(SilentModeResult result) {
// Get whether the push notification method is set for the specified conversation.
boolean enable = result.isConversationRemindTypeEnabled();
// Check if the conversation has push notifications set.
if(enable){
// Get the push notification method for the conversation.
PushManager.PushRemindType remindType = result.getRemindType();
}
// Get the offline push Do Not Disturb expiration Unix timestamp of the conversation.
long timestamp = result.getExpireTimestamp();
}
@Override
public void onError(int error, String errorMsg) {}
});Get push notification settings for multiple conversations
You can get push notification settings for up to 20 conversations in each call. If a conversation uses app settings or its push notification settings have expired, the returned dictionary does not contain such conversation.
Call getSilentModeForConversations to get the push notification settings for multiple conversations, as shown in the following sample code:
ChatClient.getInstance().pushManager().getSilentModeForConversations(conversationList, new ValueCallBack>(){
@Override
public void onSuccess(Map value) {}
@Override
public void onError(int error, String errorMsg) {}
});Clear push notification settings for a single conversation
Call clearRemindTypeForConversation to clear the push notification type for a specific conversation. After clearing, the conversation will use the app's settings by default.
The following code example shows how to clear a conversation's push notifications:
ChatClient.getInstance().pushManager().clearRemindTypeForConversation(conversationId, conversationType, new CallBack(){});To optimize the user experience when dealing with a large number of push notifications, Chat SDK provides fine-grained settings for push notifications and do not disturb mode at the app and conversation levels.
Push notification settings
| Parameter | Description | App | One-to-one and group chats |
|---|---|---|---|
All | Receive push notifications for all offline messages. | ✓ | ✓ |
MentionOnly | Receive push notifications only for mentions. This parameter is recommended for group chats. To mention one or more users, pass "em_at_list": [ "user1", "user2" ... ] to the ext field when creating a message. To mention all, 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 the push notification setting is not configured, the app setting is used by default.
For example, suppose the push notifications for the app are set to MentionOnly and the push notifications for a given conversation are set to ALL. A user will receive all push notifications from that conversation, but for all other conversations, they will only receive push notifications for messages that mention them.
After you have completed SDK initialization and successfully logged into the app, you can enable offline push for the app and various types of conversation, and turn off push by setting the Do Not Disturb 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:
| Quiet time parameters | Description | App | Single and group chat conversations |
|---|---|---|---|
silentModeStartTime & silentModeEndTime | 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 to 10 every day. If you set the start time to 8:0 and the end time to 12:0 at 11, the DND mode is effective from 11 to 12 on the same day, and from 8 to 12 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 will be turned off. If the end time is earlier than the start time, the DND mode will take 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 will take effect from 10 on that day to 8 on the next day. The DND mode can only be enabled during 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 silentModeDuration are set, the DND mode will be in effect during both time periods on the day. For example, if silentModeDuration is set to 8:0-10:0 and silentModeDuration is set to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8:00-12 on that day and from 8:00-10 every day thereafter. | ✓ | ✗ |
silentModeDuration | The DND duration, in minutes. The value range of the DND duration is [0,10080], where 0 means the parameter is invalid and 10080 means 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 you set the app-level silentModeDuration to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8 to 12 on the same day. If both this parameter and silentModeStartTime & silentModeEndTime are set, the DND mode will be effective during both time periods on the same day. For example, if the app-level silentModeStartTime & silentModeEndTime is set to 8:00-10 at 8 am and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12 now and from 8:00-10 every day thereafter. | ✓ | ✓ |
If you need to push messages to specific users during the DND period or effective time, set Force push.
For the app and all conversations in the app, the DND setting takes precedence over the push notification setting. For example, suppose a user specifies a DND time period at the app level and sets push notifications to ALL. The app enters the DND mode during the specified time period, and the user will not receive any push notifications.
Alternatively, suppose a conversation is assigned a DND time period. The app does not have any DND settings and its push notifications are set to ALL. During the specified DND time period, the user will not receive any push notifications from this conversation, while push notifications from all other conversations will remain unchanged.
Set up push notifications for the app
Call setSilentModeForAll to set app-level push notifications. Configure push notifications and the DND mode by specifying the AgoraChatSilentModeParam field, as shown in the following code example:
// Set the push notification method to `MentionOnly`.
AgoraChatSilentModeParam *param = [[AgoraChatSilentModeParam alloc]initWithParamType:AgoraChatSilentModeParamTypeRemindType];
param.remindType = AgoraChatPushRemindTypeMentionOnly;
// Set up offline push notifications for the app.
[[AgoraChatClient sharedClient].pushManager setSilentModeForAll:param completion:^(AgoraChatSilentModeResult *aResult, AgoraChatError *aError) {
if (aError) {
NSLog(@"setSilentModeForAll error---%@",aError.errorDescription);
}
}];
// Set the offline push do not disturb timer to 15 minutes.
AgoraChatSilentModeParam *param = [[AgoraChatSilentModeParam alloc]initWithParamType:AgoraChatSilentModeParamTypeDuration];
param.silentModeDuration = 15;
//Set the do not disturb time period for offline push to 8:30 to 15:00.
AgoraChatSilentModeParam *param = [[AgoraChatSilentModeParam alloc]initWithParamType:AgoraChatSilentModeParamTypeInterval];
param.silentModeStartTime = [[AgoraChatSilentModeTime alloc]initWithHours:8 minutes:30];
param.silentModeEndTime = [[AgoraChatSilentModeTime alloc]initWithHours:15 minutes:0];Get the push notification settings of the app
Call getSilentModeForAllWithCompletion to get the app-level push notification settings, as shown in the following code example:
[[AgoraChatClient sharedClient].pushManager getSilentModeForAllWithCompletion:^(AgoraChatSilentModeResult *aResult, AgoraChatError *aError) {
if (!aError) {
// Get the push notification method settings of the app.
AgoraChatPushRemindType remindType = aResult.remindType;
// Get the Unix timestamp of the app's offline push Do Not Disturb expiration.
NSTimeInterval ex = aResult.expireTimestamp;
// Get the start time of the app's offline push do not disturb time period.
AgoraChatSilentModeTime *startTime = aResult.silentModeStartTime;
// Get the end time of the offline push do not disturb time period of the app.
AgoraChatSilentModeTime *endTime = aResult.silentModeEndTime;
}else{
NSLog(@"getSilentModeForAll error---%@",aError.errorDescription);
}
}];Set push notifications for a single conversation
Call setSilentModeForConversation to set push notifications for a specified conversation. Configure push notifications and the DND mode by specifying the SilentModeParam field, as shown in the following example:
// Set the push notification method to `MentionOnly`.
AgoraChatSilentModeParam *param = [[AgoraChatSilentModeParam alloc]initWithParamType:AgoraChatSilentModeParamTypeRemindType];
param.remindType = AgoraChatPushRemindTypeMentionOnly;
// Set the offline push do not disturb timer to 15 minutes.
AgoraChatSilentModeParam *param = [[AgoraChatSilentModeParam alloc]initWithParamType:AgoraChatSilentModeParamTypeDuration];
param.silentModeDuration = 15;
// Set the offline push do not disturb mode for the conversation. Currently, it does not support setting the do not disturb time period for the conversation.
AgoraChatConversationType conversationType = AgoraChatConversationTypeGroupChat;
[[AgoraChatClient sharedClient].pushManager setSilentModeForConversation:@"conversationId" conversationType:conversationType params:param completion:^(AgoraChatSilentModeResult *aResult, AgoraChatError *aError) {
if (aError) {
NSLog(@"setSilentModeForConversation error---%@",aError.errorDescription);
}
}];Get push notification settings for a single conversation
You can call getSilentModeForConversation to get the push notification settings for a specific conversation, as shown in the following code example:
[[AgoraChatClient sharedClient].pushManager getSilentModeForConversation:@"conversationId" conversationType:AgoraChatConversationTypeChat completion:^(AgoraChatSilentModeResult * _Nullable aResult, AgoraChatError * _Nullable aError) {
}];Get push notification settings for multiple conversations
You can get push notification settings for up to 20 conversations in each call. If a conversation uses app settings or its push notification settings have expired, the returned dictionary does not contain that conversation. Call getSilentModeForConversations to get the push notification settings for multiple conversations, as shown in the following example:
AgoraChatConversation* conv1 = [AgoraChatClient.sharedClient.chatManager getConversationWithConvId:@"conversationId1"];
NSArray *conversations = @[conv1];
[[AgoraChatClient sharedClient].pushManager getSilentModeForConversations:conversations completion:^(NSDictionary*aResult, AgoraChatError *aError) {
if (aError) {
NSLog(@"getSilentModeForConversations error---%@",aError.errorDescription);
}
}];Clear push notification settings for a single conversation
Call clearRemindTypeForConversation to clear the push notification settings for a specified conversation. After clearing, this conversation will use the app's settings by default:
[[AgoraChatClient sharedClient].pushManager clearRemindTypeForConversation:@"" conversationType:conversationType completion:^(AgoraChatSilentModeResult *aResult, AgoraChatError *aError) {
if (aError) {
NSLog(@"clearRemindTypeForConversation error---%@",aError.errorDescription);
}
}];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 to 10 every day. If you set the start time to 8:0 and the end time to 12:0 at 11, the DND mode is effective from 11 to 12 on the same day, and from 8 to 12 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 on the same day to 8 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 AM and duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12 on the same day and from 8:00-10 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 am, the app will be in DND mode from 8 to 12 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 at 8 AM, and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8 to 12 and from 8 to 10 every day thereafter. | ✓ | ✓ |
If you need to push messages to specific users during the DND period or effective time, set Force push.
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
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:
/**
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
Call getSilentModeForAll to get the push notification settings of the app. The sample code is as follows:
chatClient.getSilentModeForAll();Set push notifications for a single conversation
Call setSilentModeForConversation to configure the push notification settings for a specified conversation. The sample code is as follows:
/**
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
Call getSilentModeForConversation to get the push notification settings for a single conversation. The sample code is as follows:
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
- You can get push notification settings for up to 20 conversations at a time.
- 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 :
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
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:
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);To optimize the user experience when dealing with a large number of push notifications, Chat SDK provides fine-grained settings for push notifications and do not disturb mode at the app and conversation levels.
Push notification settings
| Parameter | Description | App | One-to-one and group chats |
|---|---|---|---|
ALL | Receive push notifications for all offline messages. | ✓ | ✓ |
MENTION_ONLY | Receive push notifications only for mentions. This parameter is recommended for group chats. To mention one or more users, pass "em_at_list": [ "user1", "user2" ... ] to the ext field when creating a message. To mention all, 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 the push notification setting is not configured, the app setting is used by default.
For example, suppose the push notifications for the app are set to MENTION_ONLY and the push notifications for a given conversation are set to ALL. A user will receive all push notifications from that conversation, but for all other conversations, they will only receive push notifications for messages that mention them.
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 |
|---|---|---|---|
SILENT_MODE_INTERVAL | 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 to 10 every day. If you set the start time to 8:0 and the end time to 12:0 at 11, the DND mode is effective from 11 to 12 on the same day, and from 8 to 12 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 will be turned off. If the end time is earlier than the start time, the DND mode will take 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 will take effect from 10 on that day to 8 on the next day. The DND mode can only be enabled during 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 SILENT_MODE_DURATION are set, the DND mode will be in effect during both time periods on the day. For example, if SILENT_MODE_INTERVAL is set to 8:0-10:0 and SILENT_MODE_DURATION is set to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8:00-12 on that day and from 8:00-10 every day thereafter. | ✓ | ✗ |
SILENT_MODE_DURATION | The DND duration, in minutes. The value range of the DND duration is [0,10080], where 0 means the parameter is invalid and 10080 means 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 you set the app-level SILENT_MODE_DURATION to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8 to 12 on the same day. If both this parameter and SILENT_MODE_INTERVAL are set, the DND mode will be effective during both time periods on the same day. For example, if the app-level SILENT_MODE_INTERVAL is set to 8:00-10 at 8 am and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12 now and from 8:00-10 every day thereafter. | ✓ | ✓ |
If you need to push messages to specific users during the DND period or effective time, set Force push.
For the app and all conversations in the app, the DND setting takes precedence over the push notification setting. For example, suppose a user specifies a DND time period at the app level and sets push notifications to ALL. The app enters the DND mode during the specified time period, and the user will not receive any push notifications.
Alternatively, suppose a conversation is assigned a DND time period. The app does not have any DND settings and its push notifications are set to ALL. During the specified DND time period, the user will not receive any push notifications from this conversation, while push notifications from all other conversations will remain unchanged.
Set up push notifications for the app
Call setSilentModeForAll to set app-level push notifications. Set push notifications and DND mode by specifying the ChatSilentModeParam field, as shown in the following example:
//Set push notification mode to `MENTION_ONLY`.
ChatSilentModeParam param = ChatSilentModeParam.remindType(ChatPushRemindType.MENTION_ONLY);
//Set the offline push do not disturb timer to 15 minutes.
ChatSilentModeParam param = ChatSilentModeParam.silentDuration(15);
//Set the do not disturb time period for offline push to 8:30 to 15:00.
ChatSilentModeParam param = ChatSilentModeParam.silentModeInterval(
startTime: ChatSilentModeTime(hour: 8, minute: 30),
endTime: ChatSilentModeTime(hour: 15, minute: 0),
);
try {
//Set up offline push notifications for the app.
await ChatClient.getInstance.pushManager.setSilentModeForAll(param: param);
} on ChatError catch (e) {}Get the push notification settings of the app
Call fetchSilentModeForAll to retrieve the app-level push notification settings, as shown in the following example:
try {
ChatSilentModeResult result =
await ChatClient.getInstance.pushManager.fetchSilentModeForAll();
// Get the push notification method settings of the app.
ChatPushRemindType? remindType = result.remindType;
// Get the Unix timestamp of the app's offline push Do Not Disturb expiration.
int? timestamp = result.expireTimestamp;
// Get the start time of the app's offline push do not disturb time period.
ChatSilentModeTime? startTime = result.startTime;
// The number of hours in which the quiet time period starts.
startTime?.hour;
// The number of minutes in the start time of the do not disturb period.
startTime?.minute;
// Get the end time of the offline push do not disturb time period of the app.
ChatSilentModeTime? endTime = result.endTime;
// The number of hours in which the quiet time period ends.
endTime?.hour;
// The number of minutes in the end time of the do not disturb period.
endTime?.minute;
} on ChatError catch (e) {}Set push notifications for a single conversation
Call setSilentModeForConversation to set push notifications for a specified conversation. Configure push notifications and the DND mode by specifying the SilentModeParam field, as shown in the following example :
//Set push notification mode to `MENTION_ONLY`.
ChatSilentModeParam param = ChatSilentModeParam.remindType(ChatPushRemindType.MENTION_ONLY);
//Set the offline push do not disturb timer to 15 minutes.
ChatSilentModeParam param = ChatSilentModeParam.silentDuration(15);
try {
//Set the offline push do not disturb mode for the conversation. Currently, it does not support setting the do not disturb time period for the conversation.
ChatClient.getInstance.pushManager.setConversationSilentMode(
conversationId: conversationId,
type: conversationType,
stop: stop,
);
} on ChatError catch (e) {}Get push notification settings for a single conversation
Call fetchConversationSilentMode to retrieve the push notification setting for a specified conversation, as shown in the following example:
try {
//Set the offline push do not disturb mode for the conversation. Currently, it does not support setting the do not disturb time period for the conversation.
ChatSilentModeResult result =
await ChatClient.getInstance.pushManager.fetchConversationSilentMode(
conversationId: conversationId,
type: conversationType,
);
//Get the push notification method for the conversation.
result.remindType;
// Get the offline push Do Not Disturb expiration Unix timestamp of the conversation.
result.expireTimestamp;
} on ChatError catch (e) {}Get push notification settings for multiple conversations
You can get push notification settings for up to 20 conversations in each call. If a conversation uses app settings or its push notification settings have expired, the returned dictionary does not contain that conversation.
Call fetchSilentModeForConversations to retrieve push notification settings for multiple conversations, as shown in the following sample:
try {
Map map = await ChatClient.getInstance.pushManager.fetchSilentModeForConversations(conversationList);
} on ChatError catch (e) {}Clear push notification settings for a single conversation
Call clearRemindTypeForConversation to clear the push notification type for a specific conversation. After clearing, the conversation will use the app's settings by default:
try {
await ChatClient.getInstance.pushManager.removeConversationSilentMode(conversationId: conversationId, type: conversationType);
} on ChatError catch (e) {}To optimize the user experience when dealing with a large number of push notifications, Chat SDK provides fine-grained settings for push notifications and do not disturb mode at the app and conversation levels.
Push notification settings
| Parameter | Description | App | One-to-one and group chats |
|---|---|---|---|
ALL | Receive push notifications for all offline messages. | ✓ | ✓ |
MENTION_ONLY | Receive push notifications only for mentions. This parameter is recommended for group chats. To mention one or more users, pass "em_at_list": [ "user1", "user2" ... ] to the ext field when creating a message. To mention all, 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 the push notification setting is not configured, the app setting is used by default.
For example, suppose the push notifications for the app are set to MENTION_ONLY and the push notifications for a given conversation are set to ALL. A user will receive all push notifications from that conversation, but for all other conversations, they will only receive push notifications for messages that mention them.
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 | 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 to 10 every day. If you set the start time to 8:0 and the end time to 12:0 at 11, the DND mode is effective from 11 to 12 on the same day, and from 8 to 12 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 will be turned off. If the end time is earlier than the start time, the DND mode will take 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 will take effect from 10 on that day to 8 on the next day. The DND mode can only be enabled during 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 expireTimestamp are set, the DND mode will be in effect during both time periods on the day. For example, if startTime & endTime is set to 8:0-10:0 and expireTimestamp is set to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8:00-12 on that day and from 8:00-10 every day thereafter. | ✓ | ✗ |
expireTimestamp | The DND duration, in minutes. The value range of the DND duration is [0,10080], where 0 means the parameter is invalid and 10080 means 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 you set the app-level expireTimestamp to 240 minutes (4 hours) at 8 am, the app will be in DND mode from 8 to 12 on the same day. If both this parameter and SILENT_MODE_INTERVAL are set, the DND mode will be effective during both time periods on the same day. For example, if the app-level startTime & endTime is set to 8:00-10 at 8 am and the DND duration is set to 240 minutes (4 hours), the app will be in DND mode from 8:00-12 now and from 8:00-10 every day thereafter. | ✓ | ✓ |
If you need to push messages to specific users during the DND period or effective time, set Force push.
For the app and all conversations in the app, the DND setting takes precedence over the push notification setting. For example, suppose a user specifies a DND time period at the app level and sets push notifications to ALL. The app enters the DND mode during the specified time period, and the user will not receive any push notifications.
Alternatively, suppose a conversation is assigned a DND time period. The app does not have any DND settings and its push notifications are set to ALL. During the specified DND time period, the user will not receive any push notifications from this conversation, while push notifications from all other conversations will remain unchanged.
Set up push notifications for the app
Call setSilentModeForAll to set app-level push notifications. Set the push notifications and DND mode by specifying the ChatSilentModeParam field, as shown in the following example:
// convId: conversation ID.
// convType: conversation type.
// Set the push notification method to `MENTION_ONLY`.
const option = ChatSilentModeParam.constructorWithNotification(
ChatPushRemindType.MENTION_ONLY
);
// Set the do not disturb time to 10 minutes.
const option = ChatSilentModeParam.constructorWithDuration(10);
// Set the Do Not Disturb time period to 10:10-11:00.
const option = ChatSilentModeParam.constructorWithPeriod({
startTime: new ChatSilentModeTime({ hour: 10, minute: 10 }),
endTime: new ChatSilentModeTime({ hour: 11, minute: 10 }),
});
// Set up offline push notifications for the app.
ChatClient.getInstance()
.pushManager.setSilentModeForAll(option)
.then(() => {
console.log("Succeeded in setting the push notification.");
})
.catch((reason) => {
console.log("Failed to set the push notification.", reason);
});Get the push notification settings of the app
Call fetchSilentModeForAll to retrieve the app-level push notification settings, as shown in the following code example:
ChatClient.getInstance()
.pushManager.fetchSilentModeForAll()
.then((result) => {
console.log("Succeeded in getting the push notification settings of the app.", result);
})
.catch((reason) => {
console.log("Failed to get the push notification settings of the app.", reason);
});Set push notifications for a single conversation
Call setSilentModeForConversation to set push notifications for a specified conversation. Set the push notifications and DND mode by specifying the ChatSilentModeParam field, as shown in the following example:
// convId: conversation ID.
// convType: conversation type.
// Set the push notification method to `MENTION_ONLY`.
const option = ChatSilentModeParam.constructorWithNotification(
ChatPushRemindType.MENTION_ONLY
);
// Set the do not disturb time to 10 minutes.
const option = ChatSilentModeParam.constructorWithDuration(10);
// Set the Do Not Disturb time period to 10:10-11:00.
const option = ChatSilentModeParam.constructorWithPeriod({
startTime: new ChatSilentModeTime({ hour: 10, minute: 10 }),
endTime: new ChatSilentModeTime({ hour: 11, minute: 10 }),
});
// Set push notification for the specified conversation.
ChatClient.getInstance()
.pushManager.setSilentModeForConversation({
invited ,
convType,
option,
})
.then(() => {
console.log("Succeeded in getting the push notification settings of the conversation.");
})
.catch((reason) => {
console.log("Failed to get the push notification settings of the conversation.", reason);
});Get push notifications for a single conversation
Call fetchSilentModeForConversation to retrieve the push notification settings for a specified conversation, as shown in the following example:
// convId: conversation ID.
// convType: conversation type.
ChatClient.getInstance()
.pushManager.fetchSilentModeForConversation({
invited ,
convType,
})
.then(() => {
console.log("Succeeded in getting the push notification settings of the conversation.");
})
.catch((reason) => {
console.log("Failed to get the push notification settings of the conversation.", reason);
});Get push notification settings for multiple conversations
You can get push notification settings for up to 20 conversations in each call. If a conversation uses app settings or its push notification settings have expired, the returned dictionary does not contain that conversation.
Call fetchSilentModeForConversations to retrieve push notification settings for multiple conversations, as shown in the following example:
// conversations: conversation list.
ChatClient.getInstance()
.pushManager.fetchSilentModeForConversations(conversations)
.then(() => {
console.log("Succeeded in getting the conversation list.");
})
.catch((reason) => {
console.log("Failed to get the conversation list.", reason);
});Clear push notification settings for a single conversation
Call removeSilentModeForConversation to clear the push notification mode settings for a specific conversation. After clearing, the conversation will use the app's settings by default.
The following code example shows how to clear a conversation's push notifications:
// convId: conversation ID.
// convType: conversation type.
ChatClient.getInstance()
.pushManager.removeSilentModeForConversation({
invited ,
convType,
})
.then(() => {
console.log("Succeeded in deleting the push notification settings of the conversation.");
})
.catch((reason) => {
console.log("Failed to delete the push notification settings of the conversation.", reason);
});This feature is not supported for this platform.
This feature is not supported for this platform.
