按会话类型设置免打扰

会话类型默认级别用于“所有群都静音”“所有聊天室都静音”这类批量偏好;单会话设置仍可覆盖它。

getConversationTypeNotification​

查询按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

项值
Swiftfunc getConversationTypeNotification(conversationType: Int) async -> RcResult<IMPConversationTypeNotification>
Objective-C- (void)getConversationTypeNotificationWithConversationType:(NSInteger)conversationType completion:(void (^)(IMPOSResult *result))completion
传输REST(HTTP)
幂等是

参数​

参数类型必填说明
conversationTypeConversationType是会话类型枚举(ConversationType)

返回​

{conversationType:int, level:int}:成功返回的数据;失败时按错误码处理

示例(Swift / Objective-C)​

let res = await client.getConversationTypeNotification(conversationType: 1)
if res.code != 0 { print(res.msg ?? "") }
[client getConversationTypeNotificationWithConversationType:1 /* 单聊 */ completion:^(IMPOSResult *result) {
    if (result.code != 0) { NSLog(@"IM 调用失败:%ld %@", (long)result.code, result.msg); }
}];
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

setConversationTypeNotification​

设置按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

项值
Swiftfunc setConversationTypeNotification(conversationType: Int, level: Int) async -> RcResult<IMPConversationTypeNotification>
Objective-C- (void)setConversationTypeNotificationWithConversationType:(NSInteger)conversationType level:(NSInteger)level completion:(void (^)(IMPOSResult *result))completion
传输REST(HTTP)
幂等是

参数​

参数类型必填说明
conversationTypeConversationType是会话类型枚举(ConversationType)
levelint是字段含义见类型定义

返回​

{conversationType:int, level:int}:成功返回的数据;失败时按错误码处理

示例(Swift / Objective-C)​

let setRes = await client.setConversationTypeNotification(conversationType: 1, level: 2)
if setRes.code != 0 { print(setRes.msg ?? "") }
[client setConversationTypeNotificationWithConversationType:1 /* 单聊 */ level:2 /* 免打扰 */ completion:^(IMPOSResult *result) {
    if (result.code != 0) { NSLog(@"IM 调用失败:%ld %@", (long)result.code, result.msg); }
}];
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

使用示例​

let groupRes = await client.setConversationTypeNotification(conversationType: 2, level: 1)
if groupRes.code != 0 { print(groupRes.msg ?? "") }
[client setConversationTypeNotificationWithConversationType:2 /* 群聊 */
                                                       level:1
                                                  completion:^(IMPOSResult *result) {
    if (result.code != 0) { NSLog(@"set failed: %@", result.msg); }
}];

[client getConversationTypeNotificationWithConversationType:2 /* 群聊 */
                                                completion:^(IMPOSResult *result) {
    NSLog(@"group default level = %@", result.data);
}];

优先级示例​

类型默认单会话设置实际行为
2(免打扰)未设置所有该类型会话免打扰
2(免打扰)0(全部提醒)该会话正常提醒(单会话覆盖类型)
0(全部提醒)1(仅 @)该会话仅 @ 提醒
2(免打扰)1(仅 @)该会话仅 @ 提醒