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

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

Previous

Manage unread message counts

Next

Delete conversation

On this page

Back to top