
TUIKit or TUIConversation.login API in TUILogin to log in to the component.TUIConversationListController object. After loading, TUIConversationListController will automatically retrieve recent conversations.TUIConversationListController will trigger the didSelectConversation event.didSelectConversation, which is usually to enter the chat interface of that conversation.import UIKit// ConversationController is your own ViewControllerclass ConversationController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// TUIConversationListController_Minimalistlet vc = TUIConversationListController_Minimalist()vc.delegate = self// Option 1: push vc.navigationController?.pushViewController(vc, animated: true)// Option 2: Add TUIConversationListController_Minimalist to your own ViewController// addChild(vc)// view.addSubview(vc.view)}}extension ConversationController: TUIConversationListControllerListener {func conversationListController(_ conversationController: UIViewController, didSelectConversation conversation: TUIConversationCellData) -> Bool{// Conversation list click event, typically, opening the chat UIlet conversationData = TUIChatConversationModel()conversationData.userID = conversation.userIDconversationData.title = conversation.titleconversationData.faceUrl = conversation.faceUrl// Create chatVC by groupID or userID.var chatVC: TUIBaseChatViewController_Minimalist?if let groupID = conversationData.groupID, !groupID.isEmpty {chatVC = TUIGroupChatViewController_Minimalist()} else if let userID = conversationData.userID, !userID.isEmpty {chatVC = TUIC2CChatViewController_Minimalist()}chatVC?.conversationData = conversationData// Option 1: push chatVC.navigationController?.pushViewController(chatVC!, animated: true)// Option 2: add chatVC to your own ViewController.// addChild(chatVC!)// view.addSubview(chatVC!.view)}}
#import "TUIConversationListController_Minimalist.h"#import "TUIBaseChatViewController_Minimalist.h"#import "TUIGroupChatViewController_Minimalist.h"#import "TUIC2CChatViewController_Minimalist.h"// ConversationController is your own ViewController@implementation ConversationController- (void)viewDidLoad {[super viewDidLoad];// TUIConversationListController_MinimalistTUIConversationListController_Minimalist *vc = [[TUIConversationListController_Minimalist alloc] init];vc.delegate = self;// Option 1: push vc.[self.navigationController pushViewController:vc animated:YES];// Option 2: Add TUIConversationListController_Minimalist to your own ViewController// [self addChildViewController:vc];// [self.view addSubview:vc.view];}- (void)conversationListController:(TUIConversationListController_Minimalist *)conversationControllerdidSelectConversation:(TUIConversationCellData *)conversation {// Conversation list click event, typically, opening the chat UITUIChatConversationModel *conversationData = [TUIChatConversationModel new];conversationData.userID = conversation.userID;conversationData.title = conversation.title;conversationData.faceUrl = conversation.faceUrl;// Create chatVC by groupID or userID.TUIBaseChatViewController_Minimalist *chatVC = nil;if (conversationData.groupID.length > 0) {chatVC = [[TUIGroupChatViewController_Minimalist alloc] init];} else if (conversationData.userID.length > 0) {chatVC = [[TUIC2CChatViewController_Minimalist alloc] init];}chatVC.conversationData = conversationData;// Option 1: push chatVC.[self.navigationController pushViewController:chatVC animated:YES];// Option 2: add chatVC to your own ViewController.// [self addChildViewController:vc];// [self.view addSubview:vc.view];}@end
import UIKit// ConversationController is your own ViewControllerclass ConversationController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// TUIConversationListControllerlet vc = TUIConversationListController()vc.delegate = self// Option 1: push vc.navigationController?.pushViewController(vc, animated: true)// Option 2: Add TUIConversationListController to your own ViewController// addChild(vc)// view.addSubview(vc.view)}}extension ConversationController: TUIConversationListControllerListener {func conversationListController(_ conversationController: UIViewController, didSelectConversation conversation: TUIConversationCellData) -> Bool{// Conversation list click event, typically, opening the chat UIlet conversationData = TUIChatConversationModel()conversationData.userID = conversation.userIDconversationData.title = conversation.titleconversationData.faceUrl = conversation.faceUrl// Create chatVC by groupID or userID.var chatVC: TUIBaseChatViewController?if let groupID = conversationData.groupID, !groupID.isEmpty {chatVC = TUIGroupChatViewController()} else if let userID = conversationData.userID, !userID.isEmpty {chatVC = TUIC2CChatViewController()}chatVC?.conversationData = conversationData// Option 1: push chatVC.navigationController?.pushViewController(chatVC!, animated: true)// Option 2: add chatVC to your own ViewController.// addChild(chatVC!)// view.addSubview(chatVC!.view)}}
#import "TUIConversationListController.h"#import "TUIBaseChatViewController_Minimalist.h"#import "TUIGroupChatViewController.h"#import "TUIC2CChatViewController.h"// ConversationController is your own ViewController@implementation ConversationController- (void)viewDidLoad {[super viewDidLoad];// TUIConversationListControllerTUIConversationListController *vc = [[TUIConversationListController alloc] init];vc.delegate = self;// Option 1: push vc.[self.navigationController pushViewController:vc animated:YES];// Option 2: Add TUIConversationListController to your own ViewController// [self addChildViewController:vc];// [self.view addSubview:vc.view];}- (void)conversationListController:(TUIConversationListController *)conversationControllerdidSelectConversation:(TUIConversationCellData *)conversation {// Conversation list click event, typically, opening the chat UITUIChatConversationModel *conversationData = [TUIChatConversationModel new];conversationData.userID = conversation.userID;conversationData.title = conversation.title;conversationData.faceUrl = conversation.faceUrl;// Create chatVC by groupID or userID.TUIBaseChatViewController *chatVC = nil;if (conversationData.groupID.length > 0) {chatVC = [[TUIGroupChatViewController alloc] init];} else if (conversationData.userID.length > 0) {chatVC = [[TUIC2CChatViewControlleralloc] init];}chatVC.conversationData = conversationData;// Option 1: push chatVC.[self.navigationController pushViewController:chatVC animated:YES];// Option 2: add chatVC to your own ViewController.// [self addChildViewController:vc];// [self.view addSubview:vc.view];}@end
TUIConversationListController will show an empty list. For a better experience, it's recommended to send messages to some accounts first to trigger the creation of conversations. If you want to know how to send messages in the chat interface, please refer to the document: Build Chat Interface.Feedback