Mute a conversation
Introduction
Mute a conversation: A user can mute any conversation, and when the ZIM SDK receives a message for the conversation, it does not send a push notification, and the total count of unread messages does not increase.

Procedure
To mute a conversation, call the setConversationNotificationStatus method with the conversationID
parameter.
Sample code
// Mute a conversation
// Take a group conversation as example
zim.setConversationNotificationStatus(ZIMConversationNotificationStatus.DO_NOT_DISTURB, "CONV_ID", ZIMConversationType.PEER, new ZIMConversationNotificationStatusSetCallback() {
@Override
public void onConversationNotificationStatusSet(ZIMError errorInfo) {
// Set the callback for the results of mute notifications.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
}
});
// Mute a conversation
// Take a group conversation as example
zim.setConversationNotificationStatus(ZIMConversationNotificationStatus.DO_NOT_DISTURB, "CONV_ID", ZIMConversationType.PEER, new ZIMConversationNotificationStatusSetCallback() {
@Override
public void onConversationNotificationStatusSet(ZIMError errorInfo) {
// Set the callback for the results of mute notifications.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
}
});
Sample code
// Mute a conversation
// Take a group conversation as example
[self.zim setConversationNotificationStatus:ZIMConversationNotificationStatusDoNotDisturb conversationID:@"CONV_ID" conversationType:ZIMConversationTypePeer callback:^(ZIMError * _Nonnull errorInfo) {
// Set the callback for the mute result.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
}];
// Mute a conversation
// Take a group conversation as example
[self.zim setConversationNotificationStatus:ZIMConversationNotificationStatusDoNotDisturb conversationID:@"CONV_ID" conversationType:ZIMConversationTypePeer callback:^(ZIMError * _Nonnull errorInfo) {
// Set the callback for the mute result.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
}];
Sample code
// Mute notifications for specified conversations.
// Mute a conversation
// Take a group conversation as example
zim. setConversationNotificationStatus(ZIMConversationNotificationStatusDoNotDisturb, "CONV_ID", ZIMConversationTypePeer, [=](ZIMError errorInfo) {
// Set the callback for the results of mute notifications.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
});
// Mute notifications for specified conversations.
// Mute a conversation
// Take a group conversation as example
zim. setConversationNotificationStatus(ZIMConversationNotificationStatusDoNotDisturb, "CONV_ID", ZIMConversationTypePeer, [=](ZIMError errorInfo) {
// Set the callback for the results of mute notifications.
if(errorInfo.code == ZIMErrorCodeSuccess) {
// ......
} else {
// ......
}
});
Sample code
// Mute the notifications for a group chat.
// Take a group chat as an example
const status = 2; // Set the conversation status to "Do Not Disturb"
const conversationID = '';
const conversationType = 2; // The conversation type is a group chat
zim.setConversationNotificationStatus(status, conversationID, conversationType)
.then(function(res){
// Operation succeeded.
})
.catch(function(err){
// Operation failed.
})
// Mute the notifications for a group chat.
// Take a group chat as an example
const status = 2; // Set the conversation status to "Do Not Disturb"
const conversationID = '';
const conversationType = 2; // The conversation type is a group chat
zim.setConversationNotificationStatus(status, conversationID, conversationType)
.then(function(res){
// Operation succeeded.
})
.catch(function(err){
// Operation failed.
})
Sample code
// Set a conversation to the "Do Not Disturb" notification status
ZIM.GetInstance().SetConversationNotificationStatus(ZIMConversationNotificationStatus.DoNotDisturb, "CONV_ID",
ZIMConversationType.Group, (string conversationID, ZIMConversationType conversationType,
ZIMError errorInfo) =>
{
// Result of setting the "Do Not Disturb" notification status
});
// Set a conversation to the "Do Not Disturb" notification status
ZIM.GetInstance().SetConversationNotificationStatus(ZIMConversationNotificationStatus.DoNotDisturb, "CONV_ID",
ZIMConversationType.Group, (string conversationID, ZIMConversationType conversationType,
ZIMError errorInfo) =>
{
// Result of setting the "Do Not Disturb" notification status
});
Sample code
// Mute notifications for specified conversations.
ZIM
.getInstance()
.setConversationNotificationStatus(
ZIMConversationNotificationStatus.doNotDisturb,
'conversationID',
ZIMConversationType.group)
.then((value) {})
.catchError((onError) {});
// Mute notifications for specified conversations.
ZIM
.getInstance()
.setConversationNotificationStatus(
ZIMConversationNotificationStatus.doNotDisturb,
'conversationID',
ZIMConversationType.group)
.then((value) {})
.catchError((onError) {});