Group Management
This document guides developers on how to use RC's Instant Messaging iOS IMLib SDK to implement group management features including creating groups, setting group profiles, removing members, exiting groups, disbanding groups, and transferring group ownership.
-
This feature is supported starting from version 5.12.0.
-
For groups created via the legacy group interface
/group/create.json, group hosting-related functions are not supported by default. You need to call the "Import Group Hosting Data" interface to set the group owner and default permissions before using these features.
Service Activation
The User Profile Hosting service is enabled by default and can be used directly.
Group Events
Group events are defined in RCGroupEventDelegate, including group operations, group/member information changes, join requests, multi-device synchronization of group aliases, and multi-device synchronization of special group member attention.
-
Call
addGroupEventDelegateto add a group event callback delegate. -
Call
removeGroupEventDelegateto remove the group event callback delegate.
In the User Profile Hosting service, SDK notification callbacks triggered by group operations are also considered status notifications. Regardless of whether the application implements SDK event listeners, the server will synchronize status with the SDK to ensure local data remains up-to-date, which will be counted in message distribution and downstream data statistics.
Sample Code
// Add group event callback delegate
[[RCCoreClient sharedCoreClient] addGroupEventDelegate:self];
// ------ Group Event Callbacks ------
- (void)onGroupOperation:(NSString *)groupId
operatorInfo:(RCGroupMemberInfo *)operatorInfo
groupInfo:(RCGroupInfo *)groupInfo
operation:(RCGroupOperation)operation
memberInfos:(NSArray<RCGroupMemberInfo *> *)memberInfos
operationTime:(long long)operationTime {
// Group operation callback
// Operations include create, join, remove, exit, disband, add admin, remove admin, transfer ownership (see RCGroupOperation)
}
- (void)onGroupInfoChanged:(RCGroupMemberInfo *)operatorInfo
groupInfo:(RCGroupInfo *)groupInfo
updateKeys:(NSArray<RCGroupInfoKeys> *)updateKeys
operationTime:(long long)operationTime __deprecated_msg("Use [RCGroupEventDelegate onGroupInfoChanged:fullGroupInfo:changedGroupInfo:operationTime:] instead") {
// Group profile change callback
// Only properties included in updateKeys are valid (other properties have default values)
}
- (void)onGroupInfoChanged:(RCGroupMemberInfo *)operatorInfo
fullGroupInfo:(RCGroupInfo *)fullGroupInfo
changedGroupInfo:(RCGroupInfo *)changedGroupInfo
operationTime:(long long)operationTime {
// Group profile change callback
// fullGroupInfo: Complete group information (post-change)
// changedGroupInfo: Only changed properties
}
- (void)onGroupInfoChanged:(RCGroupMemberInfo *)operatorInfo
fullGroupInfo:(RCGroupInfo *)fullGroupInfo
changedGroupInfo:(RCGroupInfo *)changedGroupInfo
operationTime:(long long)operationTime {
// Group profile change callback
// fullGroupInfo contains complete group information
}
- (void)onGroupMemberInfoChanged:(NSString *)groupId
operatorInfo:(RCGroupMemberInfo *)operatorInfo
memberInfo:(RCGroupMemberInfo *)memberInfo
operationTime:(long long)operationTime {
// Group member profile change callback
}
- (void)onGroupApplicationEvent:(RCGroupApplicationInfo *)event {
// Group request event callback. Includes:
// 1. User join requests and their results
// 2. Group invitation requests and their results
}
- (void)onGroupRemarkChangedSync:(NSString *)groupId
operationType:(RCGroupOperationType)operationType groupRemark:(NSString *)groupRemark
operationTime:(long long)operationTime {
// Multi-device synchronization callback for group alias updates
}
- (void)onGroupFollowsChangedSync:(NSString *)groupId
operationType:(RCGroupOperationType)operationType
userIds:(NSArray<NSString *> *)userIds
operationTime:(long long)operationTime {
// Multi-device synchronization callback for special member attention changes
}
Group Management
Group management includes: creating groups, setting group profiles, removing members, exiting groups, disbanding groups, and transferring ownership.
Create Group
Call createGroup to create a new group.
Method Signature
- (void)createGroup:(RCGroupInfo *)groupInfo
inviteeUserIds:(nullable NSArray<NSString *> *)inviteeUserIds
successBlock:(void (^)(RCErrorCode processCode))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameter Description
| Parameter | Type | Required | Description |
|---|---|---|---|
| groupInfo | RCGroupInfo | Yes | Group information. |
| inviteeUserIds | NSArray | No | List of user IDs to invite when creating the group. |
| successBlock | Block | No | Success callback. |
| errorBlock | Block | No | Failure callback, returns list of error keys. |
groupInfo Parameter Details
| Parameter | Type | Required | Description |
|---|---|---|---|
| groupId | NSString | Yes | Group ID: Maximum 64 characters. Supports alphanumeric combinations. |
| groupName | NSString | Yes | Group name: Maximum 64 characters. |
| portraitUri | NSString | No | Group avatar URL: Maximum 128 characters |
| introduction | NSString | No | Group description: Maximum 512 characters |
| notice | NSString | No | Group announcement: Maximum 1024 characters |
| extProfile | NSDictionary<NSString *, NSString *> | No | Extended information: Custom attributes (Key-Value pairs) for business needs, up to 10 extensions. Custom attributes must be configured in RC Console Group Custom Attributes before use. |
| joinPermission | RCGroupJoinPermission | No | Join permissions: No verification (default), Owner verification, Owner+Admin, No one allowed |
| removeMemberPermission | RCGroupOperationPermission | No | Member removal permissions: Owner (default), Owner+Admin, All members |
| invitePermission | RCGroupOperationPermission | No | Invitation permissions: Owner (default), Owner+Admin, All members |
| inviteHandlePermission | RCGroupInviteHandlePermission | No | Invitation handling: No consent needed (default), Require consent |
| groupInfoEditPermission | RCGroupOperationPermission | No | Profile edit permissions: Owner (default), Owner+Admin, All members (Owner-only modification) |
| memberInfoEditPermission | RCGroupMemberInfoEditPermission | No | Member profile edit permissions: Self-only, Owner+Self, Owner+Admin+Self (default) |
inviteeUserIds Parameter Details
You can choose to invite users to join the group while creating it. A maximum of 30 users can be invited at once.
The invitation result is affected by the group's inviteHandlePermission parameter:
-
When invitee verification is required (value is
RCGroupInviteHandlePermissionInviteeVerify)- After successful group creation, the success callback's
processCodewill returnRC_GROUP_NEED_INVITEE_ACCEPT(25427). Invitees will receive theonGroupApplicationEventevent and must call theacceptGroupInviteinterface to join the group.
- After successful group creation, the success callback's
-
When no invitee verification is required (value is
RCGroupInviteHandlePermissionFree)- After successful group creation, the success callback's
processCodewill returnRC_SUCCESS(0), indicating invitees have joined the group.
- After successful group creation, the success callback's
-
The group creation result is not affected by
processCode- asuccesscallback indicates successful creation. -
After creation, the group owner receives the
onGroupOperationevent with operation typeRCGroupOperationCreate.
Sample Code
RCGroupInfo *groupInfo = [[RCGroupInfo alloc] init];
// Required fields
groupInfo.groupId = @"groupId";
// Required fields
groupInfo.groupName = @"groupName";
// Set other groupInfo fields as needed
// User IDs to invite (optional)
NSArray *inviteeUserIds = @[@"user1", @"user2"];
// Create group
[[RCCoreClient sharedCoreClient] createGroup:groupInfo inviteeUserIds:inviteeUserIds success:^(RCErrorCode processCode) {
// Group created successfully
if ( processCode == RC_GROUP_NEED_INVITEE_ACCEPT) {
// Invitee verification required
} else {
// No invitee verification required
}
} error:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
// Creation failed
// When errorCode == RC_SERVICE_INFORMATION_AUDIT_FAILED, errorKeys returns unapproved attribute names (e.g. groupName)
}];
Update Group Information
Call updateGroupInfo to modify group name, announcement, permissions, and other information. Only groupId is required for updates - the interface only updates modified fields.
-
All group members receive the
onGroupInfoChangedevent after successful updates. -
Only the group owner can modify the
groupInfoEditPermission.
Interface Prototype
- (void)updateGroupInfo:(RCGroupInfo *)groupInfo
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| groupInfo | RCGroupInfo | Yes | Group information. |
| successBlock | Block | No | Success callback. |
| errorBlock | Block | No | Failure callback, returns error keys. |
Sample Code
RCGroupInfo *groupInfo = [[RCGroupInfo alloc] init];
groupInfo.groupId = @"groupId";
// Update group name
groupInfo.groupName = @"newGroupName";
// Update announcement
groupInfo.notice = @"newNotice";
// Set join permission to "No verification required"
groupInfo.joinPermission = RCGroupJoinPermissionFree;
// Update group info
[[RCCoreClient sharedCoreClient] updateGroupInfo:groupInfo success:^{
// Update successful
} error:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
// Update failed
// When errorCode == RC_SERVICE_INFORMATION_AUDIT_FAILED, errorKeys returns unapproved attribute names
}];
Remove Group Members
Call kickGroupMembers to remove users from a group.
All members receive the onGroupOperation event (type RCGroupOperationKick) after successful removal.
Interface Prototype
- (void)kickGroupMembers:(NSString *)groupId
userIds:(NSArray<NSString *> *)userIds
config:(nullable RCQuitGroupConfig *)config
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | Group targetId. |
| userIds | NSArray | User IDs to remove (max 100 per operation). |
| config | RCQuitGroupConfig | Controls whether to remove followed users, allowlist users, and mute status (default: all removed). |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. |
Sample Code
RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist users (default: YES)
config.removeWhiteList = NO;
// Disable removing mute status (default: YES)
config.removeMuteStatus = NO;
[[RCCoreClient sharedCoreClient] kickGroupMembers:@"groupId" userIds:@[@"user1", @"user2"] config:config success:^{
// Removal successful
} error:^(RCErrorCode errorCode) {
// Removal failed
}];
Leave Group
Call quitGroup to voluntarily leave a group.
All members receive the onGroupOperation event (type RCGroupOperationQuit) after successful exit.
Interface Prototype
- (void)quitGroup:(NSString *)groupId
config:(nullable RCQuitGroupConfig *)config
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | Group targetId. |
| config | RCQuitGroupConfig | Controls whether to remove followed users, allowlist users, and mute status (default: all removed). |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. |
Sample Code
// Configuration for demonstration only
RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist users (default: YES)
config.removeWhiteList = NO;
// Disable removing mute status (default: YES)
config.removeMuteStatus = NO;
[[RCCoreClient sharedCoreClient] quitGroup:@"groupId" config:config success:^{
// Exit successful
} error:^(RCErrorCode errorCode) {
// Exit failed
}];
Dismiss Group
You can call the dismissGroup method to disband a group.
After successfully disbanding the group, the group conversation messages will still be retained, and local historical messages will not be deleted.
Upon successful disbanding, all group members will receive the onGroupOperation event with the operation type RCGroupOperationDismiss.
Only the group owner has the authority to disband the group.
Method Signature
- (void)dismissGroup:(NSString *)groupId
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | The targetId of the group. |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. |
Example Code
[[RCCoreClient sharedCoreClient] dismissGroup:@"groupId" success:^{
// Disband successful
} error:^(RCErrorCode errorCode) {
// Disband failed
}];
Transfer Group Ownership
You can call the transferGroupOwner method to transfer group ownership to another user.
-
Upon successful transfer, all group members will receive the
onGroupOperationevent with the operation typeRCGroupOperationTransfer. -
If you choose to quit the group during the transfer, after successful transfer, all group members will receive both the transfer event (
RCGroupOperationTransfer) and the quit event (RCGroupOperationQuit).
Only the group owner has the authority to transfer group ownership.
Method Signature
- (void)transferGroupOwner:(NSString *)groupId
newOwnerId:(NSString *)newOwnerId
quitGroup:(BOOL)quitGroup
config:(nullable RCQuitGroupConfig *)config
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameter Description
You can choose whether to quit the group after successful transfer (quitGroup). If set to YES, you can also use the config parameter (of type RCQuitGroupConfig) to control whether to remove followed users, allowlist users, and member mute status. If config is not set, all will be removed by default when quitting the group.
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | The targetId of the group. |
| newOwnerId | NSString | The userId of the new group owner. |
| quitGroup | BOOL | Whether to quit the group. |
| config | RCQuitGroupConfig | When quitting, you can set the config parameter (of type RCQuitGroupConfig) to control whether to remove followed users, allowlist users, and member mute status. If not set, all will be removed by default. |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. |
Example Code
// Group ID
NSString *groupId = @"groupId";
// New owner ID
NSString *newOwnerId = @"newOwnerId";
// Quit group after transfer
BOOL quitGroup = YES;
// Configure as needed, here for demonstration only
RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist (default: YES)
config.removeWhiteList = NO;
// Disable removing member mute status (default: YES)
config.removeMuteStatus = NO;
// Transfer ownership
[[RCCoreClient sharedCoreClient] transferGroupOwner:groupId newOwnerId:newOwnerId quitGroup:quitGroup config:nil success:^{
// Transfer successful
} error:^(RCErrorCode errorCode) {
// Transfer failed
}];
Group Alias
Feature Description
-
Group aliases are only effective for the user who sets them. When new messages are generated in the group and the user is offline, the push notification title will prioritize displaying the set group alias. If the user has not set an alias for the group, the group name will be displayed by default.
-
After successfully setting or removing the alias, other devices will receive the group alias change callback onGroupRemarkChangedSync.
Set Group Alias
You can call the setGroupRemark method to set a group alias.
To remove the group alias, pass nil or @"" for the remark parameter.
Method Signature
- (void)setGroupRemark:(NSString *)groupId
remark:(nullable NSString *)remark
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| groupId | NSString | The targetId of the group. |
| remark | NSString | The group alias. |
| successBlock | Block | Success callback. |
| errorBlock | Block | Failure callback. |
Example Code
// Set group alias
[[RCCoreClient sharedCoreClient] setGroupRemark:@"groupId" remark:@"remark" success:^{
// Set successful
} error:^(RCErrorCode errorCode) {
// Set failed
}];
// Remove group alias
// Pass nil or @"" for remark
[[RCCoreClient sharedCoreClient] setGroupRemark:@"groupId" remark:nil success:^{
// Remove successful
} error:^(RCErrorCode errorCode) {
// Remove failed
}];
Query Group Alias
You can use the getGroupsInfo method to retrieve group information, which includes the remark field.
Method Signature
- (void)getGroupsInfo:(NSArray<NSString *> *)groupIds
success:(void (^)(NSArray<RCGroupInfo *> *groupInfos))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| groupIds | NSArray | A list of group targetIds. |
| successBlock | Block | Success callback, returns a list of queried group information RCGroupInfo. |
| errorBlock | Block | Failure callback. |
Example Code
[[RCCoreClient sharedCoreClient] getGroupsInfo:@[@"groupId"] success:^(NSArray<RCGroupInfo *> * _Nonnull groupInfos) {
RCGroupInfo *groupInfo = groupInfos.firstObject;
NSString *remark = groupInfo.remark;
// Query successful
} error:^(RCErrorCode errorCode) {
// Query failed
}];
RCGroupInfo