One-to-one Chat Interface | Group Chat Interface |
| |
TUIKit
or TUIChat
.login
API in TUILogin
to log in to the component.#import "TUIBaseChatViewController_Minimalist.h"#import "TUIC2CChatViewController_Minimalist.h"#import "TUIGroupChatViewController_Minimalist.h"// ChatViewController is your own ViewController@implementation ChatViewController- (void)viewDidLoad {// Create conversation data.TUIChatConversationModel *conversationData = [[TUIChatConversationModel alloc] init];// Pass userID for 1v1 chat, while groupID for group chat.conversationData.userID = @"userID";conversationData.groupID = @"groupID";// 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 setConversationData: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 "TUIBaseChatViewController.h"#import "TUIC2CChatViewController.h"#import "TUIGroupChatViewController.h"// ChatViewController is your own ViewController@implementation ChatViewController- (void)viewDidLoad {// Create conversation data.TUIChatConversationModel *conversationData = [[TUIChatConversationModel alloc] init];// Pass userID for 1v1 chat, while groupID for group chat.conversationData.userID = @"userID";conversationData.groupID = @"groupID";// 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 = [[TUIC2CChatViewController alloc] init];}[chatVC setConversationData:conversationData];// Option 1: push chatVC.[self.navigationController pushViewController:chatVC animated:YES];// Option 2: add chatVC to your own ViewController.// [self addChildViewController:chatVC];// [self.view addSubview:chatVC.view];}@end
Was this page helpful?