User Profile Page
This feature is supported starting from version 5.12.0.
The user profile page displays basic user information. When accessing this page, the SDK retrieves user data from the database for display. IMKit provides RCProfileViewController, a profile page class based on UIKit's UITableView. The profile page distinguishes between the current user's profile and other users' profiles by initializing with different viewModels.
The IMKit conversation page does not automatically redirect to user profiles. If you wish to use this feature, you need to manually listen for events (e.g., avatar clicks via the didTapCellPortrait: method) in RCConversationViewController and handle the redirection.
Current User Profile Page
The current user profile page includes a title and user details (avatar, nickname, application ID, and gender).
Initialization
Parameters
| Parameter | Type | Description |
|---|---|---|
| viewModel | RCProfileViewModel | The business logic module for RCProfileViewController. For displaying the current user's information, initialize with RCMyProfileViewModel, a subclass of RCProfileViewModel. |
Sample Code
RCMyProfileViewModel *viewModel = [RCMyProfileViewModel new];
RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];
Modify the Title
RCProfileViewController uses the system navigation bar with a default title, which can be modified after initialization:
Sample Code
RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];
vc.title = @"custom title";
Customize Current User Profile Page Cells
1. Create a Custom RCCustomCell
@interface RCCustomCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@end
@implementation
// Cell rendering logic
@end
2. Create a Custom RCProfileCustomCellViewModel (subclass of RCProfileCellViewModel)
@interface RCProfileCustomCellViewModel : RCProfileCellViewModel
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *detail;
@end
@implementation RCProfileCustomCellViewModel
// Register and customize the cell
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = @"RCCustomCellIdentifier";
// Register the cell
[tableView registerClass:RCCustomCell.class forCellReuseIdentifier:cellIdentifier];
// Return the cell
RCCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
// Update UI
cell.titleLabel.text = self.title;
cell.contentLabel.text = self.detail;
return cell;
}
// Return cell height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 40;
}
@end
3. Set the RCProfileViewModel Delegate
Set the RCProfileViewModelDelegate when initializing the profile page:
RCMyProfileViewModel *viewModel = [RCMyProfileViewModel new];
// Add delegate
viewModel.delegate = self;
RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];