消息介绍
协作中台 提供了一套完整的消息传输管理服务,包括收发各种类型消息、消息存储、消息状态管理等。
消息模型
SDK 中用来表示消息模块的类为 KIMMessage
。具体属性说明如下:
属性 | 类型 | 说明 |
---|---|---|
chatId | String | 消息所属会话 id |
type | String | 消息类型,参考 KIMMessageType 定义 |
cid | String | 由发送端生成的唯一字符串标识 |
msgId | String | 消息的唯一 id,若消息未发送成功则为"0"或者"" |
pos | Int64 | 消息序号 |
time | Int64 | 消息发送时间,ns |
sender | String | 消息发送者 id |
extra | String | 业务方附加的透传字段 |
notices | [KIMNotice]? | 消息强提醒 |
msgConfig | KIMMsgConfig? | 消息配置 |
msgStatus | KIMMsgStatus? | 消息状态 |
recall | Bool? | 该消息是否已被撤回 |
recallInfo | KIMRecallInfo? | 撤回相关信息 recall = true 时有效 |
isReply | Bool? | 该消息是否为回复另一条消息的消息 |
replyMsg | KIMReplyMsg? | 被回复消息, isReply = true 有效 |
textMsg | KIMTextMsg? | 文本消息, type = "kim-text" 有效 |
imgMsg | KIMImageMsg? | 图片消息, type = "kim-img" 有效 |
voiceMsg | KIMVoiceMsg? | 语音消息, type = "kim-voice" 有效 |
videoMsg | KIMVideoMsg? | 视频消息, type = "kim-video" 有效 |
fileMsg | KIMFileMsg | 文件消息, type = "kim-file" 有效 |
elementMsg | KIMImgTextMsg | 图文消息, type = "kim-imgtext" 有效 |
cardMsg | KIMCardMsg | 卡片消息, type = "kim-card" 有效 |
appCustomize | KIMAppCustomizeMsg | 自定义消息, type = "kim-app-customize" 有效 |
mfMsg | KIMMergeForwardMsg | 合并消息, type = "kim-mergeforward" 有效 |
isLocalMsg | Bool | 是否为本地消息,仅代表消息获取时状态,后续需通过消息发送回调变更 |
sendStatus | KIMSendStatus | 本地消息发送状态,仅对 isLocalMsg 为 true 的自身发送中消息有效,仅代表消息获取时状态,后续需通过消息发送回调变更 |
progress | Float | 资源文件上传总进度,仅在 sendStatus = upload 时有效,仅代表消息获取时状态,后续需通过消息发送回调变更 |
KIMMsgConfig
说明:
属性 | 类型 | 说明 |
---|---|---|
unmarkUnread | Bool | 默认需要统计未读; true:不计入未读, false:计入未读(默认) 当前只适用于自定义消息 |
unmarkRecentChat | Bool | 默认更新最近会话列表; false:更新 true:不更新 |
unmarkReadStatus | Bool | 是否不生成已读未读 false: 生成, true:不生成 |
KIMMsgStatus
说明:
属性 | 类型 | 说明 |
---|---|---|
total | Int32 | 总共要阅读的人数 |
unread | Int32 | 未读的人数 |
isRead | Bool | 当前用户是否已读 |
mentionReadUsers | [String] | 被 at 的用户已读列表 |
KIMRecallInfo
说明:
属性 | 类型 | 说明 |
---|---|---|
operator | String | 消息撤回操作者 |
消息类型枚举 KIMMessageType
说明:
枚举值 | 说明 |
---|---|
text | 文本消息 |
image | 图片消息 |
voice | 语音消息 |
video | 视频消息 |
file | 文件消息 |
imgtext | 图文消息 |
card | 卡片消息 |
appCustomize | 应用自定义消息 |
mergeforward | 合并转发消息 |