logo
On this page

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.

// 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 {
      // ......
    }
});

Get a silent conversation state

After setting the mute, the client will receive the onConversationChanged notification event on the operation end and multi-end online devices.Through this event callback, the mute conversation state can be obtained. 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
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 {
      // ......
    }
});

Previous

Manage unread message counts

Next

Delete conversation

On this page

Back to top