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.

Enable for mute a conversation
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) {});
Get a silent conversation state
After setting the mute, the client will receive the conversationChanged notification event on the operation end and multi-end online devices.
After the offline device re-logs in, the mute conversation state can be obtained through the ZIMConversation.notificationStatus
property of the conversation list.
// 1. Listen for conversation change events
public void onConversationChanged(ZIM zim, ArrayList<ZIMConversationChangeInfo> conversationChangeInfoList) {
super.onConversationChanged(zim, conversationChangeInfoList);
// conversationChangeInfoList.get(0).conversation.notificationStatus
}
// 2. Query the conversation list
ZIMConversationQueryConfig config = new ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
zim.queryConversationList(config, new ZIMConversationListQueriedCallback() {
@Override
public void onConversationListQueried(ArrayList<ZIMConversation> conversationList, ZIMError errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCode.SUCCESS) {
// conversationList.get(0).notificationStatus
} else {
// ......
}
}
});
// 1. Listen for conversation change events
public void onConversationChanged(ZIM zim, ArrayList<ZIMConversationChangeInfo> conversationChangeInfoList) {
super.onConversationChanged(zim, conversationChangeInfoList);
// conversationChangeInfoList.get(0).conversation.notificationStatus
}
// 2. Query the conversation list
ZIMConversationQueryConfig config = new ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
zim.queryConversationList(config, new ZIMConversationListQueriedCallback() {
@Override
public void onConversationListQueried(ArrayList<ZIMConversation> conversationList, ZIMError errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCode.SUCCESS) {
// conversationList.get(0).notificationStatus
} else {
// ......
}
}
});
// 1. Listen for conversation change events
- (void)zim:(ZIM *)zim conversationChanged:(NSArray<ZIMConversationChangeInfo *> *)conversationChangeInfoList {
// Get the conversation change list
for (ZIMConversationChangeInfo *info in conversationChangeInfoList) {
// info.conversation.notificationStatus
}
}
// 2. Query the conversation list
ZIMConversationQueryConfig *config = [[ZIMConversationQueryConfig alloc] init];
config.count = 10;
config.nextConversation = nil;
[self.zim queryConversationListWithConfig:config callback:^(NSArray<ZIMConversation *> * _Nonnull conversationList, ZIMError * _Nonnull errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCodeSuccess) {
for (ZIMConversation *info in conversationList) {
// info.notificationStatus
}
} else {
// ......
}
}];
// 1. Listen for conversation change events
- (void)zim:(ZIM *)zim conversationChanged:(NSArray<ZIMConversationChangeInfo *> *)conversationChangeInfoList {
// Get the conversation change list
for (ZIMConversationChangeInfo *info in conversationChangeInfoList) {
// info.conversation.notificationStatus
}
}
// 2. Query the conversation list
ZIMConversationQueryConfig *config = [[ZIMConversationQueryConfig alloc] init];
config.count = 10;
config.nextConversation = nil;
[self.zim queryConversationListWithConfig:config callback:^(NSArray<ZIMConversation *> * _Nonnull conversationList, ZIMError * _Nonnull errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCodeSuccess) {
for (ZIMConversation *info in conversationList) {
// info.notificationStatus
}
} else {
// ......
}
}];
// 1. Listen for conversation change events
void onConversationChanged(ZIM * zim, const std::vector<ZIMConversationChangeInfo> & conversationChangeInfoList) {
// Get the conversation change list
for (auto &info : conversationChangeInfoList) {
// info.conversation.notificationStatus
}
}
// 2. Query the conversation list
ZIMConversationQueryConfig config;
config.count = 10;
config.nextConversation = nullptr;
zim->queryConversationList(config, [=](std::vector<std::shared_ptr<ZIMConversation>> conversationList, ZIMError errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCodeSuccess) {
for (auto &info : conversationList) {
// info.notificationStatus
}
} else {
// ......
}
});
// 1. Listen for conversation change events
void onConversationChanged(ZIM * zim, const std::vector<ZIMConversationChangeInfo> & conversationChangeInfoList) {
// Get the conversation change list
for (auto &info : conversationChangeInfoList) {
// info.conversation.notificationStatus
}
}
// 2. Query the conversation list
ZIMConversationQueryConfig config;
config.count = 10;
config.nextConversation = nullptr;
zim->queryConversationList(config, [=](std::vector<std::shared_ptr<ZIMConversation>> conversationList, ZIMError errorInfo) {
// Get the conversation list query result
if(errorInfo.code == ZIMErrorCodeSuccess) {
for (auto &info : conversationList) {
// info.notificationStatus
}
} else {
// ......
}
});
// 1. Listen for conversation change events
zim.on('conversationChanged', (zim: ZIM, data: ZIMEventOfConversationChangedResult) => {
console.log(data.infoList[0].conversation.notificationStatus);
});
// 2. Query the conversation list
const config: ZIMConversationQueryConfig = { count: 10, nextConversation: null };
zim.queryConversationList(config, null)
.then((res: ZIMConversationListQueriedResult) => {
// Query succeeded
console.log(res.conversationList[0].notificationStatus);
})
.catch((err: ZIMError) => {
// Query failed
});
// 1. Listen for conversation change events
zim.on('conversationChanged', (zim: ZIM, data: ZIMEventOfConversationChangedResult) => {
console.log(data.infoList[0].conversation.notificationStatus);
});
// 2. Query the conversation list
const config: ZIMConversationQueryConfig = { count: 10, nextConversation: null };
zim.queryConversationList(config, null)
.then((res: ZIMConversationListQueriedResult) => {
// Query succeeded
console.log(res.conversationList[0].notificationStatus);
})
.catch((err: ZIMError) => {
// Query failed
});
// 1. Listen for conversation change events
ZIM.GetInstance().onConversationChanged = (
ZIM zim, List<ZIMConversationChangeInfo> conversationChangeInfoList) =>
{
// Conversation change notification
};
// 2. Query the conversation list
ZIMConversationQueryConfig config = new ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
// Pull the conversation list
ZIM.GetInstance().QueryConversationList(config, (List<ZIMConversation> conversationList,
ZIMError errorInfo) =>
{
// Pull the result callback
});
// 1. Listen for conversation change events
ZIM.GetInstance().onConversationChanged = (
ZIM zim, List<ZIMConversationChangeInfo> conversationChangeInfoList) =>
{
// Conversation change notification
};
// 2. Query the conversation list
ZIMConversationQueryConfig config = new ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
// Pull the conversation list
ZIM.GetInstance().QueryConversationList(config, (List<ZIMConversation> conversationList,
ZIMError errorInfo) =>
{
// Pull the result callback
});
// 1. Listen for conversation change events
ZIMEventHandler.onConversationChanged = (ZIM zim, List<ZIMConversationChangeInfo> conversationChangeInfoList){
// conversationChangeInfoList[0].conversation.notificationStatus
};
// 2. Query the conversation list
ZIMConversationQueryConfig config = ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
ZIM
.getInstance()
!.queryConversationList(config)
.then((res) => {
// res.conversationList[0].notificationStatus
})
.catchError((onError) {});
// 1. Listen for conversation change events
ZIMEventHandler.onConversationChanged = (ZIM zim, List<ZIMConversationChangeInfo> conversationChangeInfoList){
// conversationChangeInfoList[0].conversation.notificationStatus
};
// 2. Query the conversation list
ZIMConversationQueryConfig config = ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
ZIM
.getInstance()
!.queryConversationList(config)
.then((res) => {
// res.conversationList[0].notificationStatus
})
.catchError((onError) {});