logo
即时通讯
客户端 SDK
当前页

设置会话免打扰


功能概述

会话消息免打扰,指设置之后,SDK 在接收到当前会话的消息时,将不会进行推送通知,同时 “消息未读总数”也不会增加

消息免打扰.png

开启免打扰

调用 setConversationNotificationStatus 接口,传入 conversationID 指定某个会话,设置消息免打扰功能。

// 将某个会话设置成消息免打扰状态
// 以群聊会话为例
ZIM
    .getInstance()
    !.setConversationNotificationStatus(
        ZIMConversationNotificationStatus.doNotDisturb,
        'conversationID',
        ZIMConversationType.group)
    .then((value) => {})
    .catchError((onError) {});

获取免打扰状态

设置免打扰后,客户端本地存在该会话的操作端和多端在线设备,都将会收到 onConversationChanged 通知事件。 离线设备重新登录后,可通过查询会话列表的 ZIMConversation.notificationStatus 属性获取会话免打扰状态。

// 1. 监听会话变更事件
ZIMEventHandler.onConversationChanged = (ZIM zim, List<ZIMConversationChangeInfo> conversationChangeInfoList){
    // conversationChangeInfoList[0].conversation.notificationStatus 
};

// 2. 查询会话列表
ZIMConversationQueryConfig config = ZIMConversationQueryConfig();
config.count = 10;
config.nextConversation = null;
ZIM
    .getInstance()
    !.queryConversationList(config)
    .then((res) => {
      // res.conversationList[0].notificationStatus
    })
    .catchError((onError) {});

Previous

管理消息未读数

Next

删除会话

当前页

返回到顶部