logo
In-app Chat
SDK Error Codes
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 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.
    })

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

Previous

Manage unread message counts

Next

Delete conversation

On this page

Back to top