未读数
未读数由服务端累加,客户端进入会话后可清零;支持 @ 提醒未读单独计数。
平台调用风格
双语言同契约:Swift 用 async -> RcResult<T>(错误码在 RcResult.code,返回 null 的 op 用 RcResult<Void>);Objective-C 用 - (void)opWithParam:... completion:(void (^)(RcResult *))completion,回调在主线程投递。
接口一览
| 操作 | 语义 | 传输 | 返回 |
|---|---|---|---|
clearUnreadCount | 清空会话未读(等价 read 帧 + 本地清零)。 | WS 长连接 | null |
本页 1 个操作,其中 1 个在本平台绑定中声明了方法签名。
跨端方法名
| 操作 | Android | Web | Electron | macOS | Flutter | Native (C ABI) | iOS |
|---|---|---|---|---|---|---|---|
clearUnreadCount | clearUnreadCount | clearUnreadCount | clearUnreadCount | clearUnreadCount | clearUnreadCount | — | func |
方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。
clearUnreadCount
清空会话未读(等价 read 帧 + 本地清零)。
func clearUnreadCount(conversationType: IMPConversationType, targetId: String) async -> RcResult<Void>参数
| 参数 | 类型 | 说明 |
|---|---|---|
conversationType | ConversationType | 必填;会话类型枚举(ConversationType) |
targetId | string | 必填;目标会话 ID:单聊为对方 userId,群聊为 groupId,聊天室为 chatroomId |
返回
null 无返回数据;成功与否通过错误码判断
示例(Swift / Objective-C)
let res = await client.clearUnreadCount(conversationType: .privateChat, targetId: "user2")
if res.code != 0 { print("IM 调用失败:\(res.msg ?? "")") }[client clearUnreadCountWithConversationType:1 /* 单聊 */ targetId:@"user2" completion:^(IMPOSResult *result) {
if (result.code != 0) { NSLog(@"IM 调用失败:%ld %@", (long)result.code, result.msg); }
}];该操作未声明专属错误码;失败时按 SDK 通用错误处理,见 状态码。
相关文档
- 功能列表:103 个操作与签名
- 状态码:错误码与重试策略
- API 参考:类与成员
- IMLib 集成指南