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 "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 "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.
Was this page helpful?