集成会话列表界面
协作中台 SDK 支持会话列表的集成,会话列表功能如下:
- 根据消息生成会话列表,即最近聊天记录。
- 将指定的某类会话聚合,如消息助手。
效果展示

可以通过两种方式集成会话列表页面:
- 直接使用
KIMChatListViewController
类,集成默认的会话列表界面。 - 继承使用
KIMChatListViewController
类,通过实现协议自定义会话列表界面。
代码示例
- 直接使用
KIMChatListViewController
。
swift
let controller = KIMChatListViewController()
self.navigationController.pushViewController(controller, animated: true)
Objective-C
KIMChatListViewController *controller = [[KIMChatListViewController alloc] init];
[self.navigationController pushViewController:controller animated:YES];
- 继承使用
KIMChatListViewController
。
swift
// 1. 继承自会话列表视图控制器。
class CustomChatListViewController: KIMChatListViewController, KIMChatListViewControllerDelegate {
// 2. 重写初始化方法,设置页面自定义协议代理。
required init() {
super.init()
// 设置页面定制化协议代理。
self.delegate = self
}
override func viewDidLoad() {
super.viewDidLoad()
}
// 3. 实现页面自定义协议方法。
func chatListViewController(_ controller: KIMChatListViewController, configTitleView titleView: KIMChatTitleView) {
// 实现标题栏配置方法完成标题栏样式自定义。
}
// ...
}
// 4. 使用自定义的视图控制器。
let controller = CustomChatListViewController()
self.navigationController.pushViewController(controller, animated: true)
// 5. 如果需要SDK内部全局替换成自定义的子类(如 CustomChatListViewController),可注册子类类型。
KIM.chatModule.chatListViewControllerType = CustomChatListViewController.self