Skip to main content

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.

tip
  • 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 addGroupEventDelegate to add a group event callback delegate.

  • Call removeGroupEventDelegate to remove the group event callback delegate.

tip

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

ParameterTypeRequiredDescription
groupInfoRCGroupInfoYesGroup information.
inviteeUserIdsNSArrayNoList of user IDs to invite when creating the group.
successBlockBlockNoSuccess callback.
errorBlockBlockNoFailure callback, returns list of error keys.

groupInfo Parameter Details

ParameterTypeRequiredDescription
groupIdNSStringYesGroup ID: Maximum 64 characters. Supports alphanumeric combinations.
groupNameNSStringYesGroup name: Maximum 64 characters.
portraitUriNSStringNoGroup avatar URL: Maximum 128 characters
introductionNSStringNoGroup description: Maximum 512 characters
noticeNSStringNoGroup announcement: Maximum 1024 characters
extProfileNSDictionary<NSString *, NSString *>NoExtended 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.
joinPermissionRCGroupJoinPermissionNoJoin permissions: No verification (default), Owner verification, Owner+Admin, No one allowed
removeMemberPermissionRCGroupOperationPermissionNoMember removal permissions: Owner (default), Owner+Admin, All members
invitePermissionRCGroupOperationPermissionNoInvitation permissions: Owner (default), Owner+Admin, All members
inviteHandlePermissionRCGroupInviteHandlePermissionNoInvitation handling: No consent needed (default), Require consent
groupInfoEditPermissionRCGroupOperationPermissionNoProfile edit permissions: Owner (default), Owner+Admin, All members (Owner-only modification)
memberInfoEditPermissionRCGroupMemberInfoEditPermissionNoMember 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 processCode will return RC_GROUP_NEED_INVITEE_ACCEPT (25427). Invitees will receive the onGroupApplicationEvent event and must call the acceptGroupInvite interface to join the group.
  • When no invitee verification is required (value is RCGroupInviteHandlePermissionFree)

    • After successful group creation, the success callback's processCode will return RC_SUCCESS (0), indicating invitees have joined the group.
tip
  • The group creation result is not affected by processCode - a success callback indicates successful creation.

  • After creation, the group owner receives the onGroupOperation event with operation type RCGroupOperationCreate.

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.

tip
  • All group members receive the onGroupInfoChanged event 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

ParameterTypeRequiredDescription
groupInfoRCGroupInfoYesGroup information.
successBlockBlockNoSuccess callback.
errorBlockBlockNoFailure 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

ParameterTypeDescription
groupIdNSStringGroup targetId.
userIdsNSArrayUser IDs to remove (max 100 per operation).
configRCQuitGroupConfigControls whether to remove followed users, allowlist users, and mute status (default: all removed).
successBlockBlockSuccess callback.
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdNSStringGroup targetId.
configRCQuitGroupConfigControls whether to remove followed users, allowlist users, and mute status (default: all removed).
successBlockBlockSuccess callback.
errorBlockBlockFailure 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.

tip

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

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
successBlockBlockSuccess callback.
errorBlockBlockFailure 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 onGroupOperation event with the operation type RCGroupOperationTransfer.

  • 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).

tip

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.

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
newOwnerIdNSStringThe userId of the new group owner.
quitGroupBOOLWhether to quit the group.
configRCQuitGroupConfigWhen 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.
successBlockBlockSuccess callback.
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
remarkNSStringThe group alias.
successBlockBlockSuccess callback.
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdsNSArrayA list of group targetIds.
successBlockBlockSuccess callback, returns a list of queried group information RCGroupInfo.
errorBlockBlockFailure 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