群事件
进行会话相应操作、群聊成员变更后,系统将会下发相应的事件结果,您可以注册相关代理来监听群事件。
监听群事件
接口定义
swift
func register(chatDelegate: KIMChatDelegate)
Objective-C
- (void)registerWithChatDelegate:(id <KIMChatDelegate> _Nonnull)chatDelegate;
参数说明
参数 | 类型 | 说明 |
---|---|---|
chatDelegate | KIMChatDelegate | 会话事件代理 |
代码示例
swift
KIMCore.shared.register(chatDelegate: self)
事件说明
入群退群相关
接口定义
swift
func didReceivedChatOwnerGroupAction(chatId: String, action: String)
Objective-C
- (void)didReceivedChatOwnerGroupActionWithChatId:(NSString * _Nonnull)chatId action:(NSString * _Nonnull)action;
参数说明
参数 | 类型 | 说明 |
---|---|---|
chatId | String | 会话 ID |
action | String | 事件,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;
参数说明
参数 | 类型 | 说明 |
---|---|---|
chatId | String | 会话 ID |
operator | String | 事件操作者 ID |
action | String | 事件,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;
参数 | 类型 | 说明 |
---|---|---|
chatId | String | 会话 ID |
newName | String | 新的群名 |
群成员禁言事件
接口定义
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;
参数 | 类型 | 说明 |
---|---|---|
chatId | String | 会话 ID |
enabledUid | [String] | 解除禁言用户列表 |
disableUid | [String] | 添加禁言用户列表 |