My Groups Page
This feature is supported starting from version 5.12.2.
The My Groups page displays all groups the current user has joined. Upon entering this page, the IMKit SDK automatically retrieves group information from the database.
IMKit provides RCMyGroupsViewController
, a group list page class based on UITableView
.
The My Groups page typically consists of three components: navigation bar, search bar, and group list.

Initialization
Initialize the list page by calling the initialization method of the RCMyGroupsViewController
class.
Note: You need to create an RCMyGroupsViewModel object as the business logic handler for RCMyGroupsViewController
.
Parameter Description
Parameter | Type | Description |
---|---|---|
viewModel | RCMyGroupsViewModel | The business logic handler for RCMyGroupsViewController . Manages UI configuration and group information retrieval. |
Sample Code
RCMyGroupsViewModel *viewModel = [[RCMyGroupsViewModel alloc] init];
RCMyGroupsViewController *vc = [[RCMyGroupsViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];
Customization
The style of the IMKit My Groups interface can be customized.
Custom Title Bar
IMKit's RCMyGroupsViewController
uses the system navigation bar to display the group title. By subclassing RCMyGroupsViewController
, you can set a custom title via the title
property in the viewDidLoad
method.
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"New Title";
}
Custom Search Bar
By default, the search bar in RCMyGroupsViewController
redirects to the group search page. You can customize the search functionality by setting the delegate
property of RCMyGroupsViewModel
and implementing custom search delegate methods.
Sample Code
RCMyGroupsViewModel *viewModel = [[RCMyGroupsViewModel alloc] init];
viewModel.delegate = self;
RCMyGroupsViewController *vc = [[RCMyGroupsViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];
...
/// Configure custom search functionality
- (RCSearchBarViewModel *_Nullable)willConfigureSearchBarViewModelForMyGroupsViewModel:(RCMyGroupsViewModel *)viewModel {
// Return custom search ViewModel
}
Custom My Groups Page Cell
1. Create RCCustomCell
@interface RCCustomCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation
// Cell rendering
@end
2. Create RCCustomCellViewModel
Custom CellViewModels must subclass RCGroupInfoCellViewModel.
@interface RCCustomCellViewModel : RCGroupInfoCellViewModel
@property (nonatomic, strong) RCGroupInfo *groupInfo;
/// Initialization
/// - keyword: Highlight keyword
- (instancetype)initWithGroupInfo:(RCGroupInfo *)groupInfo
keyword:(NSString *)keyword;
@end
@implementation RCCustomCellViewModel
- (instancetype)initWithGroupInfo:(RCGroupInfo *)groupInfo
keyword:(NSString *)keyword
{
self = [super init];
if (self) {
self.groupInfo = groupInfo;
self.keyword = keyword;
}
return self;
}
// Register and customize cell
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = @"RCCustomCellIdentifier";
// Register cell
[tableView registerClass:RCCustomCell.class forCellReuseIdentifier:cellIdentifier];
// Return cell
RCCustomCellViewModel *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
// Modify UI
cell.titleLabel.text = self.groupInfo.groupName;
...
return cell;
}
@end
3. Modify Data Source
Implement the data source callback delegate method:
// Data source
- (NSArray *_Nullable)myGroupsViewModel:(RCMyGroupsViewModel *)viewModel
willLoadItemsInDataSource:(NSArray *_Nullable)dataSource{
// Process data source (add/delete/modify)
}
4. Custom Cell Tap Event
/// Configure custom tap events. Returns: Whether the app handles the event [YES: SDK won't process, NO: SDK handles internally]
- (BOOL)myGroupsViewModel:(RCMyGroupsViewModel *)viewModel
viewController:(UIViewController*)viewController
tableView:(UITableView *)tableView
didSelectRow:(NSIndexPath *)indexPath
cellViewModel:(RCBaseCellViewModel *)cellViewModel {
}