Skip to main content

Group Management

This document guides developers on using RC's iOS IMLib SDK to implement group management features including creating groups, configuring group profiles, removing members, leaving groups, disbanding groups, and transferring group ownership.

tip
  • This feature is supported starting from version 5.12.0
  • For groups created via the legacy /group/create.json interface, you must call the "Import Group Hosting Data" interface to set the group owner (Group Owner) and default permissions before using group hosting features

Enabling the Service

Before using this feature, you must enable the profile hosting service by submitting a ticket.

Group Events

Group events are defined in RCGroupEventDelegate, including group operations, group/member information changes, join requests, multi-device synchronization of group aliases, and special follow synchronization.

  • Call addGroupEventDelegate to add group event callbacks
  • Call removeGroupEventDelegate to remove group event callbacks
tip

In User Profile Hosting service, SDK notification callbacks triggered by group operations count as status notifications. The server synchronizes status with the SDK regardless of whether your app implements event listeners, ensuring local data remains current. These actions are included 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/leave/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 listed in updateKeys are valid (others retain default values)
}

- (void)onGroupInfoChanged:(RCGroupMemberInfo *)operatorInfo
fullGroupInfo:(RCGroupInfo *)fullGroupInfo
changedGroupInfo:(RCGroupInfo *)changedGroupInfo
operationTime:(long long)operationTime {
// Group profile change callback
// fullGroupInfo: Complete group info (post-change)
// changedGroupInfo: Only modified 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 including:
// 1. User join requests/results
// 2. Invitation requests/results
}

- (void)onGroupRemarkChangedSync:(NSString *)groupId
operationType:(RCGroupOperationType)operationType groupRemark:(NSString *)groupRemark
operationTime:(long long)operationTime {
// Multi-device group alias synchronization
}

- (void)onGroupFollowsChangedSync:(NSString *)groupId
operationType:(RCGroupOperationType)operationType
userIds:(NSArray<NSString *> *)userIds
operationTime:(long long)operationTime {
// Multi-device special follow synchronization
}

Group Management

Features include: create group, configure group profile, remove members, leave group, disband group, and transfer 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;

Parameters

ParameterTypeRequiredDescription
groupInfoRCGroupInfoYesGroup information
inviteeUserIdsNSArrayNoUser IDs to invite during creation
successBlockBlockNoSuccess callback
errorBlockBlockNoFailure callback (returns error keys)

groupInfo Parameters

ParameterTypeRequiredDescription
groupIdNSStringYesGroup ID (max 64 chars, alphanumeric)
groupNameNSStringYesGroup name (max 64 chars)
portraitUriNSStringNoGroup avatar URL (max 128 chars)
introductionNSStringNoGroup description (max 512 chars)
noticeNSStringNoGroup announcement (max 1024 chars)
extProfileNSDictionary<NSString *, NSString *>NoCustom attributes (max 10 key-value pairs). Must configure via Console Group Custom Attributes first
joinPermissionRCGroupJoinPermissionNoJoin permissions: no verification (default), owner approval, admin+owner, or closed
removeMemberPermissionRCGroupOperationPermissionNoMember removal permissions: owner (default), owner+admin, or all members
invitePermissionRCGroupOperationPermissionNoInvite permissions: owner (default), owner+admin, or all members
inviteHandlePermissionRCGroupInviteHandlePermissionNoInvitation handling: no consent needed (default) or require consent
groupInfoEditPermissionRCGroupOperationPermissionNoProfile edit permissions: owner (default), owner+admin, or all members (owner-only modifiable)
memberInfoEditPermissionRCGroupMemberInfoEditPermissionNoMember profile edit permissions: self-only, owner+self, or owner+admin+self (default)

RCGroupInviteHandlePermission | No | Invitation handling: no consent needed (default) or require consent. Uses default value if not set | | groupInfoEditPermission | RCGroupOperationPermission | No | Profile edit permissions: owner (default), owner+admin, or all members (owner-only modifiable). Uses default value if not set | | memberInfoEditPermission | RCGroupMemberInfoEditPermission | No | Member profile edit permissions: self-only, owner+self, or owner+admin+self (default). Uses default value if not set |

inviteeUserIds Parameter Description

You can optionally invite users to join the group during creation. A maximum of 30 users can be invited at once.

The invitation outcome depends on the group's inviteHandlePermission parameter:

  • When invitee verification is required (RCGroupInviteHandlePermissionInviteeVerify)
    • After successful group creation, the callback's processCode returns RC_GROUP_NEED_INVITEE_ACCEPT (25427). Invitees receive the onGroupApplicationEvent event and must call the acceptGroupInvite method to join.
  • When no verification is required (RCGroupInviteHandlePermissionFree)
    • After successful group creation, the callback's processCode returns RC_SUCCESS (0), indicating invitees have joined automatically.
tip
  • Group creation success isn't affected by processCode - any success callback means the group was created.
  • After creation, the owner receives the onGroupOperation event with operation type RCGroupOperationCreate.
  • By default, profile information isn't subject to moderation. Enable moderation in the Console under App Configuration > Security & Moderation > IM & RTC Moderation > IM Information Hosting Configuration.

Code Example

RCGroupInfo *groupInfo = [[RCGroupInfo alloc] init];
// Required
groupInfo.groupId = @"groupId";
// Required
groupInfo.groupName = @"groupName";
// Set other groupInfo fields as needed

// Optional: User IDs to invite
NSArray *inviteeUserIds = @[@"user1", @"user2"];

// Create group
[[RCCoreClient sharedCoreClient] createGroup:groupInfo inviteeUserIds:inviteeUserIds success:^(RCErrorCode processCode) {
// Group created
if ( processCode == RC_GROUP_NEED_INVITEE_ACCEPT) {
// Requires invitee verification
} else {
// No verification needed
}
} 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 the group name, announcement, permissions, or other details. Only groupId is required - other fields are updated only if modified.

tip
  • All members receive the onGroupInfoChanged event after updates.
  • Only owners can modify the groupInfoEditPermission.
  • Enable moderation in the Console under App Configuration > Security & Moderation > IM & RTC Moderation > IM Information Hosting Configuration.

Method Signature

- (void)updateGroupInfo:(RCGroupInfo *)groupInfo
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;

Parameters

ParameterTypeRequiredDescription
groupInfoRCGroupInfoYesGroup information.
successBlockBlockNoSuccess callback.
errorBlockBlockNoFailure callback with error keys.

Example

RCGroupInfo *groupInfo = [[RCGroupInfo alloc] init];
groupInfo.groupId = @"groupId";
// Update name
groupInfo.groupName = @"newGroupName";
// Update notice
groupInfo.notice = @"newNotice";
// Set join permission to "no verification"
groupInfo.joinPermission = RCGroupJoinPermissionFree;

[[RCCoreClient sharedCoreClient] updateGroupInfo:groupInfo success:^{
// Update succeeded
} error:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
// Update failed
// When errorCode == RC_SERVICE_INFORMATION_AUDIT_FAILED, errorKeys returns unapproved attributes
}];

Remove Group Members

Call kickGroupMembers to remove users from a group. All members receive the onGroupOperation event with operation type RCGroupOperationKick after removal.

Method Signature

- (void)kickGroupMembers:(NSString *)groupId
userIds:(NSArray<NSString *> *)userIds
config:(nullable RCQuitGroupConfig *)config
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameters

ParameterTypeDescription
groupIdNSStringGroup targetId.
userIdsNSArrayUser IDs to remove (max 100).
configRCQuitGroupConfigControls whether to remove followed users, allowlist members, and mute status (default: all removed).
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Code Example

RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist (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 succeeded
} error:^(RCErrorCode errorCode) {
// Removal failed
}];

After successfully leaving, all group members will receive an onGroupOperation event with the operation type RCGroupOperationQuit.

Method Signature

- (void)quitGroup:(NSString *)groupId
config:(nullable RCQuitGroupConfig *)config
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameters

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
configRCQuitGroupConfigYou can set the config parameter (type RCQuitGroupConfig) when quitting to control whether to remove followed users, allowlist users, and member mute status. If not set, all will be removed by default.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Example Code

// Configure as needed, this is just for demonstration
RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist (default: YES)
config.removeWhiteList = NO;
// Disable removing mute status (default: YES)
config.removeMuteStatus = NO;

[[RCCoreClient sharedCoreClient] quitGroup:@"groupId" config:config success:^{
// Quit successfully
} error:^(RCErrorCode errorCode) {
// Quit failed
}];

Dismiss Group

You can call the dismissGroup method to disband a group.
After successfully disbanding, group chat messages will remain, and local history messages will not be deleted.
All group members will receive an onGroupOperation event with the operation type RCGroupOperationDismiss.

tip

Only the group owner has permission to disband the group.

Method Signature

- (void)dismissGroup:(NSString *)groupId
success:(void (^)(void))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameters

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Example Code

[[RCCoreClient sharedCoreClient] dismissGroup:@"groupId" success:^{
// Dismissed successfully
} error:^(RCErrorCode errorCode) {
// Dismiss failed
}];

Transfer Group Ownership

You can call the transferGroupOwner method to transfer group ownership to another user.

  • After successful transfer, all group members will receive an onGroupOperation event with the operation type RCGroupOperationTransfer.
  • If you choose to leave the group during the transfer, members will receive both the transfer event (RCGroupOperationTransfer) and the quit event (RCGroupOperationQuit).
tip

Only the group owner has permission to transfer 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;

Parameters

You can choose whether to leave the group after transferring ownership (quitGroup). If set to YES, you can also use the config parameter (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 leaving the group.

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
newOwnerIdNSStringThe userId of the new group owner.
quitGroupBOOLWhether to leave the group after transfer.
configRCQuitGroupConfigYou can set the config parameter (type RCQuitGroupConfig) when quitting to control whether to remove followed users, allowlist users, and member mute status. If not set, all will be removed by default.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Example Code

// Group ID
NSString *groupId = @"groupId";
// New owner ID
NSString *newOwnerId = @"newOwnerId";
// Leave group after transfer
BOOL quitGroup = YES;

// Configure as needed, this is just for demonstration
RCQuitGroupConfig *config = [[RCQuitGroupConfig alloc] init];
// Disable removing followed users (default: YES)
config.removeFollow = NO;
// Disable removing allowlist (default: YES)
config.removeWhiteList = NO;
// Disable removing 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 only take effect for the user who sets them. When new messages are generated in the group and the user is offline, the push title will display the group alias if set. If no alias is set, the group name will be displayed by default.
  • After successfully setting or removing an alias, other devices will receive the multi-device sync callback onGroupRemarkChangedSync.

Set Group Alias

You can call the setGroupRemark method to set a group alias.

To remove a 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;
ParameterTypeDescription
groupIdNSStringThe targetId of the group.
remarkNSStringGroup alias.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Sample Code

// Set group alias
[[RCCoreClient sharedCoreClient] setGroupRemark:@"groupId" remark:@"remark" success:^{
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];

// Remove group alias
// Pass nil or @"" for remark
[[RCCoreClient sharedCoreClient] setGroupRemark:@"groupId" remark:nil success:^{
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];

Query Group Alias

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

ParameterTypeDescription
groupIdsNSArrayList of group targetIds.
successBlockBlockSuccess callback, returns queried group information RCGroupInfo list.
errorBlockBlockFailure callback.

Sample Code

[[RCCoreClient sharedCoreClient] getGroupsInfo:@[@"groupId"] success:^(NSArray<RCGroupInfo *> * _Nonnull groupInfos) {
RCGroupInfo *groupInfo = groupInfos.firstObject;
NSString *remark = groupInfo.remark;
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];

RCGroupInfo