批量会话设置免打扰
本文描述如何为指定批量会话设置免打扰级别。
提示
即时通讯客户端 SDK 支持多维度、多级别的免打扰设置。
- App 开发者可实现从 App Key、用户级别多个维度的免打扰功能配置。在融云服务端决定是否触发推送通知时,不同维度的优先级如下:用户级别设置 > App Key 级设置。
- 用户级别设置下包含多个细分维度。在融云服务端决定是否触发推送通知时,如存在用户级别配置,不同细分维度的优先级如下:全局免打扰 > 按会话设置的免打扰 。详见免打扰功能概述。
支持的免打扰级别
免打扰级别提供了针对不同 @ 消息的免打扰控制。指定会话的免打扰配置支持以下级别:
枚举值 | 取值 | 说明 |
---|---|---|
PushNotificationLevel.All | -1 | 与融云服务端断开连接后,当前用户可针对指定类型会话中的所有消息接收通知。 |
PushNotificationLevel.Default | 0 | 未设置。未设置时均为此初始状态。 |
PushNotificationLevel.Mention | 1 | 与融云服务端断开连接后,当前用户仅针对指定类型的会话中提及(@)当前用户和全体群成员的消息接收通知。 |
PushNotificationLevel.MentionUsers | 2 | 与融云服务端断开连接后,当前用户仅针对指定类型的会话中提及(@)当前用户的消息接收通知。例如:张三只会接收 “@张三 Hello” 的消息的通知。 |
PushNotificationLevel.MentionAll | 4 | 与融云服务端断开连接后,当前用户仅针对指定类型的会话中提及(@)全部群成员的消息接收通知。 |
PushNotificationLevel.Blocked | 5 | 当前用户针对指定类型的会话中的任何消息都不接收推送通知。 |
管理会话的免打扰设置
即时通讯业务用户(userId)为指定会话(targetId)设置免打扰级别,支持单聊、群聊、系统会话。
设置指定会话免打扰级别
您可以为当前用户设置指定批量会话的免打扰级别。
接口原型
TypeScript
public setConversationsNotificationLevel(conIdList: List<ConversationIdentifier>, level: PushNotificationLevel): Promise<IAsyncResult<void>>;
参数说明
参数 | 类型 | 说明 |
---|---|---|
conIdList | List<ConversationIdentifier> | 会话标识数组。请注意以下限制:
|
level | PushNotificationLevel | 见上面的详细描述 |
示例代码
TypeScript
let conIdList = new List<ConversationIdentifier>();
let conId1 = new ConversationIdentifier();
conId1.conversationType = ConversationType.Private;
conId1.targetId = "会话 id";
conIdList.add(conId1)
let conId2 = new ConversationIdentifier();
conId2.conversationType = ConversationType.Private;
conId2.targetId = "会话 id";
conIdList.add(conId2)
let level = PushNotificationLevel.Blocked;
IMEngine.getInstance().setConversationsNotificationLevel(conIdList, level)
.then(result => {
if (EngineError.Success !== result.code) {
// 设置免打扰失败
return;
}
});