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

群事件

进行会话相应操作、群聊成员变更后,系统将会下发相应的事件结果,您可以注册相关代理来监听群事件。

监听群事件

接口定义

swift
func register(chatDelegate: KIMChatDelegate)
Objective-C
- (void)registerWithChatDelegate:(id <KIMChatDelegate> _Nonnull)chatDelegate;

参数说明

参数类型说明
chatDelegateKIMChatDelegate会话事件代理

代码示例

swift
KIMCore.shared.register(chatDelegate: self)

事件说明

入群退群相关

接口定义

swift
func didReceivedChatOwnerGroupAction(chatId: String, action: String)
Objective-C
- (void)didReceivedChatOwnerGroupActionWithChatId:(NSString * _Nonnull)chatId action:(NSString * _Nonnull)action;

参数说明

参数类型说明
chatIdString会话 ID
actionString事件,KIMChatOwnerGroupAction 枚举值

KIMChatOwnerGroupAction 说明:

枚举值说明
dismiss解散群聊
member_kicked自己被踢出群聊
member_leaved自己退出群聊
member_entered自己被人邀请入群

群成员相关

接口定义

swift
@objc optional func didReceivedChatGroupAction(chatId: String, operator: String, action: String, targets: [String])
Objective-C
- (void)didReceivedChatGroupActionWithChatId:(NSString *)chatId operator:(NSString *)operator action:(NSString *)action targets:(NSArray<NSString *> *)targets;

参数说明

参数类型说明
chatIdString会话 ID
operatorString事件操作者 ID
actionString事件,KIMChatGroupAction 枚举值
targets[String]事件被操作用户 id 组

KIMChatGroupAction 说明:

枚举值说明
member_entered群成员入群
member_kicked群成员被踢出群聊
member_leaved群成员退出群聊
transfer_owner转让群主,原群主自动失去群主身份
set_admin设置管理员
del_admin取消管理员

群设置相关

群聊重命名事件

接口定义
swift
func didReceivedChatRename(chatId: String, newName: String)
Objective-C
- (void)didReceivedChatRenameWithChatId:(NSString *)chatId newName:(NSString *)newName;
参数类型说明
chatIdString会话 ID
newNameString新的群名

群成员禁言事件

接口定义
swift
@objc optional func didReceivedChatMemberSendStatus(chatId: String, enabledUid: [String], disableUid: [String])
Objective-C
- (void)didReceivedChatMemberSendStatusWithChatId:(NSString *)chatId enabledUid:(NSArray<NSString *> *)enabledUid disableUid:(NSArray<NSString *> *)disableUid;
参数类型说明
chatIdString会话 ID
enabledUid[String]解除禁言用户列表
disableUid[String]添加禁言用户列表