This article will guide you through the process of building a conversation list interface.
Display Effect
The effect of the conversation list is shown below:
Environment Requirements
Xcode 10 or later
iOS 9.0 or later
Preconditions
Before building the interface, please ensure that you have completed the following 4 things:
1. Created an application in the console.
2. Created some user accounts in the console.
3. Integrated with TUIKit or TUIConversation.
4. Called the login API in TUILogin to log in to the component.
Note:
1. All components use this API to log in. You can log in once every time you start the application.
2. Please make sure that the login is successful, and we recommend that you do the following in the callback of successful login.
If you haven't completed the above 4 steps, please refer to the corresponding steps in Getting Started first, otherwise you may encounter obstacles when implementing the following features.
If you have already completed them, please continue reading below.
Step Instructions
Building a conversation list usually involves the following 3 steps:
1. Load the conversation list. The list corresponds to the TUIConversationListController object. After loading, TUIConversationListController will automatically retrieve recent conversations.
2. When a user clicks on a row in the conversation list, TUIConversationListController will trigger the didSelectConversation event.
3. Respond to the click in didSelectConversation, which is usually to enter the chat interface of that conversation.
// Option 2: add chatVC to your own ViewController.
// [self addChildViewController:vc];
// [self.view addSubview:vc.view];
}
@end
Note:
If you haven't sent messages to any person or group before, no conversation will be generated. In this case, loading the 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.