Skip to main content

Group Member Management

This document guides developers on how to use RC IM iOS IMLib SDK to implement functions such as setting or querying group member profiles, adding or removing group administrators.

tip

This feature is supported starting from version 5.12.0.

Service Activation

The information hosting service is enabled by default, and you can use this feature directly.

Group Members

You can query members of a specified group or set group member information.

Paginated Retrieval of Group Members by Role

You can use getGroupMembersByRole to retrieve group member information paginated by role.

The result in the success callback of this interface will return the total number of members that meet the query conditions.

Interface Prototype

- (void)getGroupMembersByRole:(NSString *)groupId
role:(RCGroupMemberRole)role
option:(RCPagingQueryOption *)option
success:(void (^)(RCPagingQueryResult<RCGroupMemberInfo *> *result))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameter Description

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
roleRCGroupMemberRoleThe role of the group member.
optionRCPagingQueryOptionQuery options, including page token (optional, if not provided, returns the first page of data), number of items per page (maximum 200), and whether to query in ascending order (default is descending).
successBlockBlockSuccess callback, returns the relevant query data as an RCPagingQueryResult array.
errorBlockBlockFailure callback.

Role Parameter Introduction

Type: RCGroupMemberRole

Enum ValueDescription
RCGroupMemberRoleUndefUndefined role (using this enum means querying all types of group members)
RCGroupMemberRoleNormalRegular group member
RCGroupMemberRoleManagerAdministrator
RCGroupMemberRoleOwnerGroup Owner

Option Parameter Introduction

Type: RCPagingQueryOption

ParameterTypeDescription
pageTokenNSStringPage token. For the first fetch, you can pass nil or @"". If the result (type RCPagingQueryResult) returned in the success callback has a pageToken that is not @"", you can pass this value to fetch the next page until pageToken returns as @"", indicating all data has been fetched.
countNSIntegerNumber of items per page, maximum 100 per page
orderBOOLDefault NO for descending order by join time, YES for ascending order

Sample Code

- (void)getGroupMembersByRole:(NSString *)pageToken {
// Group ID
NSString *groupId = @"groupId";

// The role of group members to retrieve, this example retrieves members of all roles
RCGroupMemberRole role = RCGroupMemberRoleUndef;

// Query options
RCPagingQueryOption *option = [[RCPagingQueryOption alloc] init];
// Page token, pass nil for the first page
option.pageToken = pageToken;
// Number of items per page
option.count = 20;
// Default NO for descending order by join time, YES for ascending order
option.order = NO;

[[RCCoreClient sharedCoreClient] getGroupMembersByRole:groupId
role:role
option:option
success:^(RCPagingQueryResult<RCGroupMemberInfo *> * _Nonnull result) {
// Success
if (result.pageToken.length > 0) {
// Continue fetching the next page
[self getGroupMembersByRole:result.pageToken];
} else {
// Fetch complete, no more data
}

} error:^(RCErrorCode errorCode) {
// Failure
}];
}

Retrieve Group Member Information

You can use getGroupMembers to retrieve group member information for specified users in a specified group.
A single call supports retrieving information for up to 100 members.

tip

If the current user is not a member of the specified group, group member information cannot be retrieved.

Interface Prototype

- (void)getGroupMembers:(NSString *)groupId
userIds:(NSArray<NSString *> *)userIds
success:(void (^)(NSArray<RCGroupMemberInfo *> *groupMembers))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameter Description

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
userIdsNSArrayList of user userIds.
successBlockBlockSuccess callback, returns the relevant query data as an RCPagingQueryResult array.
errorBlockBlockFailure callback.

Sample Code

// Group ID
NSString *groupId = @"groupId";
// Specified user userIds
NSArray *userIds = @[@"user1", @"user2"];

// Retrieve group member information for specified users
[[RCCoreClient sharedCoreClient] getGroupMembers:groupId
userIds:userIds
success:^(NSArray<RCGroupMemberInfo *> * _Nonnull groupMembers) {
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];

Paginated Retrieval of Group Members by Nickname

You can use searchGroupMembers to paginate and search for group member information in a specified local group.
The search prioritizes matching the group member nickname nickname, then the group member username name. A match in either field will return the search result.

The result in the success callback of this interface will return the total number of members that meet the query conditions.

Interface Prototype

- (void)searchGroupMembers:(NSString *)groupId
name:(NSString *)name
option:(RCPagingQueryOption *)option
success:(void (^)(RCPagingQueryResult<RCGroupMemberInfo *> *result))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameter Description

| Parameter | Type | Description | | ------- | --------| -------- | ------------------------------------------ | | groupId | NSString| The targetId of the group.| | name | NSString | Group member nickname, required, cannot be empty, maximum 64 characters.| | option | RCPagingQueryOption| Query options, including page token (optional, if not provided, returns the first page of data), number of items per page (maximum 200), and whether to query in ascending order (default is descending).| | successBlock | Block | Success callback, returns the relevant query data as an RCPagingQueryResult array. | | errorBlock | Block | Failure callback. |

Option Parameter Introduction

Type: RCPagingQueryOption

ParameterTypeDescription
pageTokenNSStringPage token. For the first fetch, you can pass nil or @"". If the result (type RCPagingQueryResult) returned in the success callback has a pageToken that is not @"", you can pass this value to fetch the next page until pageToken returns as @"", indicating all data has been fetched.
countNSIntegerNumber of items per page, maximum 200 per page
orderBOOLSort by join time (default NO for descending, YES for ascending)

Sample Code



- (void)searchGroupMembers:(NSString *)pageToken {
// Group ID
NSString *groupId = @"groupId";
// Group member nickname
NSString *name = @"";

// Role of group members to retrieve (example shows retrieving members of all roles)
RCGroupMemberRole role = RCGroupMemberRoleUndef;

// Query options
RCPagingQueryOption *option = [[RCPagingQueryOption alloc] init];
// Page token (pass nil for first page)
option.pageToken = pageToken;
// Items per page
option.count = 20;
// Default NO for descending order by join time, YES for ascending
option.order = NO;

// Search group members by nickname
[[RCCoreClient sharedCoreClient] searchGroupMembers:groupId
name:name
option:option
success:^(RCPagingQueryResult<RCGroupMemberInfo *> * _Nonnull result) {
// Search successful
if (result.pageToken.length > 0) {
// Continue searching next page
[self getGroupMembersByRole:result.pageToken];
} else {
// Search completed, no more data
}

} error:^(RCErrorCode errorCode) {
// Search failed
}];
}

Set Group Member Information

You can use setGroupMemberInfo to configure information for specified group members. The memberInfoEditPermission determines whether group member information can be modified. Calls will return an error code if you lack permission.

Upon successful API call, all group members will receive the onGroupMemberInfoChanged callback for group member information updates.

API Prototype



- (void)setGroupMemberInfo:(NSString *)groupId
userId:(NSString *)userId
nickname:(nullable NSString *)nickname
extra:(nullable NSString *)extra
successBlock:(void (^)(void))successBlock
errorBlock:(void (^)(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys))errorBlock;

Parameters

ParameterTypeDescription
groupIdNSStringGroup ID
userIdNSStringGroup member user ID
nicknameNSStringGroup member nickname (max 64 chars). Pass nil or @"" to clear nickname.
extraNSStringGroup member additional info (max 128 chars). Pass nil or @"" to clear additional info.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Code Example

// Group ID
NSString *groupId = @"groupId";
// Group member user ID
NSString *userId = @"user1";
// Group member nickname
NSString *nickname = @"nickname";
// Group member additional info (optional)
NSString *extra = @"Group member additional info";

[[RCCoreClient sharedCoreClient] setGroupMemberInfo:groupId
userId:userId
nickname:nickname
extra:extra
success:^{
// Configuration successful
} error:^(RCErrorCode errorCode, NSArray<NSString *> * _Nullable errorKeys) {
// Configuration failed
// When errorCode == RC_SERVICE_INFORMATION_AUDIT_FAILED, errorKeys returns attribute names that failed moderation (e.g. nickname)
}];

Group Administrators

You can add or remove group administrators.

Add Group Administrators

Use addGroupManagers to add group administrators. Upon successful API call, all group members will receive the onGroupOperation callback with operation type RCGroupOperationAddManager.

tip
  • Only group owners can add administrators.

  • Target members must be group members, and group owners cannot be set as administrators.

  • Maximum 10 administrators per group.

API Prototype



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

Parameters

ParameterTypeDescription
groupIdNSStringGroup targetId (required)
userIdsNSArrayUser ID array (required). User IDs must belong to group members. Maximum 10 administrators per operation (10 max per group). Group owners cannot be set as administrators.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Code Example

// Group ID
NSString *groupId = @"groupId";
// User IDs to set as administrators
NSArray *userIds = @[@"user1", @"user2"];

// Add group administrators
[[RCCoreClient sharedCoreClient] addGroupManagers:groupId userIds:userIds success:^{
// Configuration successful
} error:^(RCErrorCode errorCode) {
// Configuration failed
}];

Remove Group Administrators

Use removeGroupManagers to remove group administrators. Maximum 10 administrators can be removed per operation.

Upon successful API call, all group members will receive the onGroupOperation callback with operation type RCGroupOperationRemoveManager.

tip
  • Only group owners can remove administrators.

API Prototype



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

Parameters

ParameterTypeDescription
groupIdNSStringGroup targetId (required)
userIdsNSArrayUser ID array (required). Maximum 10 administrators per operation.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Code Example

// Group ID
NSString *groupId = @"groupId";
// User IDs to remove as administrators
NSArray *userIds = @[@"user1", @"user2"];

// Add group administrators
[[RCCoreClient sharedCoreClient] removeGroupManagers:groupId userIds:userIds success:^{
// Removal successful
} error:^(RCErrorCode errorCode) {
// Removal failed
}];

Members I Follow

You can add, remove, or query group members you follow.

Features

  • Maximum 200 members you can follow per group.

  • Messages from followed members bypass conversation Do Not Disturb settings and trigger normal notifications.

  • Push notification priority for messages from followed members:

    • App-level Do Not Disturb (no push) > Message marked as silent > Sender is followed member > Conversation Do Not Disturb setting
  • For Do Not Disturb details, see Do Not Disturb Overview

  • Upon successful configuration/removal, the user's other logged-in devices will receive the multi-device sync callback onGroupFollowsChangedSync for followed member changes.

Add Members I Follow

You can use addGroupFollows to add members to your follow list. A single call supports following up to 100 group members.

Method Signature



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

Parameter Description

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
userIdsNSArrayAn array of user IDs. Maximum 100 users per call.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Example Code

// Group ID
NSString *groupId = @"groupId";
// User IDs to follow
NSArray *userIds = @[@"user1", @"user2"];

// Add members to follow list
[[RCCoreClient sharedCoreClient] addGroupFollows:groupId userIds:userIds success:^{

} error:^(RCErrorCode errorCode) {

}];

Remove Members I Follow

You can use removeGroupFollows to remove members from your follow list. This method supports batch removal - you can pass multiple userId values (up to 100) in a single call.

Method Signature



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

Parameter Description

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
userIdsNSArrayAn array of user IDs. Maximum 100 users per call.
successBlockBlockSuccess callback.
errorBlockBlockFailure callback.

Example Code

// Group ID
NSString *groupId = @"groupId";
// User IDs to unfollow
NSArray *userIds = @[@"user1", @"user2"];

// Remove members from follow list
[[RCCoreClient sharedCoreClient] removeGroupFollows:groupId userIds:userIds success:^{
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];

Query Members I Follow

You can use getGroupFollows to query your list of followed members.

Method Signature



- (void)getGroupFollows:(NSString *)groupId
success:(void (^)(NSArray<RCFollowInfo *> *followInfos))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;

Parameter Description

ParameterTypeDescription
groupIdNSStringThe targetId of the group.
successBlockBlockSuccess callback, returns an array of RCFollowInfo objects.
errorBlockBlockFailure callback.

Example Code

// Group ID
NSString *groupId = @"groupId";

// Get followed members
[[RCCoreClient sharedCoreClient] getGroupFollows:groupId
success:^(NSArray<RCFollowInfo *> * _Nonnull followInfos) {
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];