Skip to content
能力中心
产品中心
应用市场
WebOffice
开发者后台

接收消息

开发者拦截 SDK 接收的消息,并进行相应的业务操作。

接收消息监听

通过注册消息监听代理来接收会话的新消息。

接口定义

swift
func register(messageDelegate: KIMMessageDelegate)
Objective-C
- (void)registerWithMessageDelegate:(id <KIMMessageDelegate> )messageDelegate;

参数说明

参数类型说明
messageDelegateKIMMessageDelegate消息事件息代理

KIMMessageDelegate 接收消息相关代理方法说明:

方法参数说明
didReceivedMessagemessage: KIMMessage 消息数据接收到会话的新消息,包含从当前端发送形成本地消息及云端生成的新消息
didReceivedMessageStatuschatId: String 消息所在会话id msgId: String 消息id msgStatus: KIMMsgStatus 消息状态接收到消息状态更新
didReceivedMessageReplyInfoschatId: String 消息所在会话id infos: [KIMMsgReplyOperation] 消息快捷回复数据接收到消息快捷回复

KIMMsgStatus 说明:

参数类型说明
totalInt32总共要阅读的人数
unreadInt32未读的人数
isReadBool当前用户是否已读
mentionReadUsers[String]被 at 的用户已读列表

KIMMsgReplyOperation 说明:

参数类型说明
msgIdString消息 id
replyIdInt64回复 id(emoji id)
ctimeInt64emoji 的第一次被回复的时间
items[KIMMsgReplyItem]操作内容

KIMMsgReplyItem 说明:

参数类型说明
userIdString用户 id
ctimeInt64回复时间
replyCidInt64客户端本地 id,服务端原封不动返回
stateInt32状态,0:撤销,1:添加

代码示例

swift
KIMCore.shared.register(messageDelegate: self)