Skip to main content

Group Pages

tip

This feature is supported starting from version 5.12.0.

Group-related pages include contact selection, group creation, group settings, and group member lists.

Enable the Service

Before using this feature, you must enable the User Profile Hosting service in the Console.

Contact Selection/Addition Page

The contact selection/addition page class is RCSelectUserViewController.

By default, this page displays the current user's friend list from the User Profile Hosting service.

Initialization

Call the initialization method of the RCSelectUserViewController class to build the friend list page.
Note: You need to create an RCSelectUserViewModel object as the business logic handler for RCSelectUserViewController.

Parameter Description

RCSelectUserViewController parameters:

ParameterTypeDescription
viewModelRCSelectUserViewModelThe business logic handler for RCSelectUserViewController. Fetches and processes the contact list display logic.

RCSelectUserViewModel parameters:

ParameterTypeDescription
typeRCSelectUserTypeContact selection type: RCSelectUserTypeCreateGroup for group creation or RCSelectUserTypeInviteJoinGroup for adding members to a group.
groupIdNSStringGroup ID (optional). Required when type is RCSelectUserTypeInviteJoinGroup.

Sample Code

// Group ID (optional). Required when type is `RCSelectUserTypeInviteJoinGroup`.
RCSelectUserViewModel *vm = [RCSelectUserViewModel viewModelWithType:RCSelectUserTypeCreateGroup groupId:nil];
RCSelectUserViewController *vc = [[RCSelectUserViewController alloc] initWithViewModel:vm];
[self.navigationController pushViewController:vc animated:YES];

Configure Maximum Selectable Users

IMKit allows configuring the maximum number of selectable users per session via the maxSelectCount property of RCSelectUserViewModel. The default is 30. The configured value must be > 0 and ≤ 100.

Sample Code

RCSelectUserViewModel *vm = [RCSelectUserViewModel viewModelWithType:RCSelectUserTypeCreateGroup groupId:nil];
// Default max selectable count is 30
vm.maxSelectCount = 50;
RCSelectUserViewController *vc = [[RCSelectUserViewController alloc] initWithViewModel:vm];
[self.navigationController pushViewController:vc animated:YES];

Intercept Selection Completion Callback

Use the RCSelectUserViewModelDelegate protocol to intercept the selection completion callback.

  1. Add the delegate:
RCSelectUserViewModel *vm = [RCSelectUserViewModel viewModelWithType:RCSelectUserTypeCreateGroup groupId:nil];
vm.delegate = self;
RCSelectUserViewController *vc = [[RCSelectUserViewController alloc] initWithViewModel:vm];
[self.navigationController pushViewController:vc animated:YES];
  1. Implement the interception method:
- (BOOL)selectUserDidSelectComplete:(RCSelectUserViewModel *)viewModel
selectUserIds:(NSMutableArray <NSString *>*)selectUserIds
viewController:(UIViewController*)viewController {
return YES; // YES: SDK won't handle it; NO: SDK handles it
}

Group Creation Page

The group creation page class is RCGroupCreateViewController.

Initialization

Call the initialization method of RCGroupCreateViewController to build the page.
Note: Create an RCGroupCreateViewModel object as the business logic handler.

Parameter Description

RCGroupCreateViewController parameters:

ParameterTypeDescription
viewModelRCGroupCreateViewModelBusiness logic handler for group creation.

RCGroupCreateViewModel parameters:

ParameterTypeDescription
inviteeUserIdsNSArray <NSString *>*List of selected user IDs (excluding the current user).
delegateRCGroupCreateViewModelDelegateDelegate.

Sample Code

NSArray *selectUserIds = @[@"userId1", @"userId2"];
RCGroupCreateViewModel *viewModel = [RCGroupCreateViewModel viewModelWithInviteeUserIds:self.selectUserIds];
viewModel.delegate = self;
RCGroupCreateViewController *vc = [[RCGroupCreateViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];
tip

Since the group ID must be provided by you, implement the generateGroupId method of RCGroupCreateViewModelDelegate to supply it to the IMKit SDK.

Sample Code

- (NSString *)generateGroupId {
return @"groupId";
}

Custom Avatar Click Event

To customize group avatar selection during creation, implement the avatar click method in RCGroupCreateViewModelDelegate:

- (void)groupPortraitDidClick:(UIViewController *)inViewController
resultBlock:(void(^)(NSString *portraitUrl))resultBlock {
// Navigate to avatar selection and return the result via resultBlock
NSString *portraitRemoteUrl = @"Remote avatar URL after upload";
resultBlock(portraitRemoteUrl);
}

Group Settings Page

Note: The "Do Not Disturb" and "Pin Conversation" cells shown in the image are demo implementations via custom cells and are not part of the built-in page.

Initialization

Call the initialization method of RCProfileViewController to build the page.
Note: Use an RCGroupProfileViewModel object as the business logic handler.

The same RCProfileViewController class is used for both group settings and user profiles, differentiated by the ViewModel type passed during initialization.

Parameter Description

RCProfileViewController parameters:

ParameterTypeDescription
viewModelRCProfileViewModelBusiness logic handler. Use RCGroupProfileViewModel (a subclass) for group settings.

RCGroupProfileViewModel parameters:

ParameterTypeDescription
groupIdNSStringGroup ID.

Sample Code

RCGroupProfileViewModel *viewModel = [RCGroupProfileViewModel viewModelWithGroupId:self.targetId];
RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];

Custom Title

The built-in navigation bar title defaults to "Group Name (Member Count)". You can customize it after initialization:

RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];
vc.title = @"custom title";

Configure Displayed Member Count

Use the displayMaxMemberCount property of RCGroupProfileViewModel to set the maximum number of members displayed. Default is 30. The value must be ≥ 5 and ≤ 50.

RCGroupProfileViewModel *viewModel = [RCGroupProfileViewModel viewModelWithGroupId:self.targetId];
viewModel.delegate = self;
/// Max displayed members (default: 30). Must be between 5 and 50.
viewModel.displayMaxMemberCount = 20;
RCProfileViewController *vc = [[RCProfileViewController alloc] initWithViewModel:viewModel];

Customize Group Settings Cells

RCGroupProfileViewModel and RCMyProfileViewModel inherit from the same parent class RCProfileViewModel. Refer to the Current User Profile Page Custom Cells logic, replacing RCMyProfileViewModel with RCGroupProfileViewModel when checking for group settings pages.

Group Member List Page

Initialization

Clicking the member list cell in group settings navigates to this page by default. To customize or navigate from elsewhere, initialize using RCGroupMemberListViewController with an RCGroupMemberListViewModel.

Parameter Description

RCGroupMemberListViewController parameters:

ParameterTypeDescription
viewModelRCGroupMemberListViewModelBusiness logic handler for member list display.

RCGroupMemberListViewModel parameters:

ParameterTypeDescription
groupIdNSStringGroup ID.

Sample Code

RCGroupMemberListViewModel *viewModel = [RCGroupMemberListViewModel viewModelWithGroupId:self.groupId];
RCGroupMemberListViewController *membersVC = [[RCGroupMemberListViewController alloc] initWithViewModel:viewModel];
membersVC.title = @"Group Members";
[self.navigationController pushViewController:membersVC animated:YES];

Configure Members per Page

Set the pageCount property of RCGroupMemberListViewModel during initialization. Default is 50. Value must be > 0 and ≤ 100:

RCGroupMemberListViewModel *viewModel = [RCGroupMemberListViewModel viewModelWithGroupId:self.groupId];
/// Members per page (default: 50). Must be between 1 and 100.
viewModel.pageCount = 60

Custom Member Click Event

By default, clicking a member navigates to the built-in user profile page. To customize:

  1. Set the delegate:
RCGroupMemberListViewModel *viewModel = [RCGroupMemberListViewModel viewModelWithGroupId:group.groupId];
viewModel.delegate = self;
  1. Implement the click handler:
- (BOOL)groupMemberList:(RCGroupMemberListViewModel *)viewModel
viewController:(UIViewController*)viewController
tableView:(UITableView *)tableView
didSelectRow:(NSIndexPath *)indexPath
cellViewModel:(RCGroupMemberCellViewModel *)cellViewModel {
return YES; // YES: SDK won't handle it; NO: SDK handles it
}

Remove Members Page

Initialization

The group settings page includes navigation to this page by default. To customize or navigate from elsewhere, initialize RCRemoveGroupMembersViewController with an RCRemoveGroupMembersViewModel.

Parameter Description

RCRemoveGroupMembersViewController parameters:

ParameterTypeDescription
viewModelRCRemoveGroupMembersViewModelBusiness logic handler for member removal.

RCRemoveGroupMembersViewModel parameters:

ParameterTypeDescription
groupIdNSStringGroup ID.

Sample Code

RCRemoveGroupMembersViewModel *viewModel = [RCRemoveGroupMembersViewModel viewModelWithGroupId:group.groupId];
RCRemoveGroupMembersViewController *vc = [[RCRemoveGroupMembersViewController alloc] initWithViewModel:viewModel];
[self.navigationController pushViewController:vc animated:YES];

Configure Maximum Removable Members per Session

Set the maxSelectCount property of RCRemoveGroupMembersViewModel. Default is 30. Value must be > 0 and ≤ 100:

RCRemoveGroupMembersViewModel *viewModel = [RCRemoveGroupMembersViewModel viewModelWithGroupId:group.groupId];
/// Max selectable count per session (default: 30). Must be between 1 and 100.
viewModel.maxSelectCount = 60

Custom Member Click Event

To override the default profile navigation:

  1. Set the delegate:
RCRemoveGroupMembersViewModel *viewModel = [RCRemoveGroupMembersViewModel viewModelWithGroupId:group.groupId];
viewModel.delegate = self;
  1. Implement the handler:
- (BOOL)groupRemoveMembers:(RCRemoveGroupMembersViewModel *)viewModel
viewController:(UIViewController*)viewController
tableView:(UITableView *)tableView
didSelectRow:(NSIndexPath *)indexPath
cellViewModel:(RCRemoveGroupMemberCellViewModel *)cellViewModel {
return YES; // YES: SDK won't handle it; NO: SDK handles it
}

Intercept Removal Completion Callback

To customize post-selection behavior:

  1. Set the delegate:
RCRemoveGroupMembersViewModel *viewModel = [RCRemoveGroupMembersViewModel viewModelWithGroupId:group.groupId];
viewModel.delegate = self;
  1. Implement the callback:
- (BOOL)groupRemoveMembersDidSelectComplete:(RCRemoveGroupMembersViewModel *)viewModel
selectUserIds:(NSMutableArray <NSString *>*)selectUserIds
viewController:(UIViewController*)viewController {
return YES; // YES: SDK won't handle it; NO: SDK handles it
}