Group Member Management
This document guides developers on how to use RC's IMLib SDK to implement features such as setting or querying group member profiles, adding or removing group administrators.
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 Member Information
You can use [getGroupMembersByRole] to retrieve group member information by role in paginated format.
This interface supports returning the total count of query results, see getTotalCount() in [PagingQueryOption].
Group member role GroupMemberRole enumeration:
| Enum Value | Group Member Role |
|---|---|
| Undef | Undefined role (using this enum queries all types of group members) |
| Normal | Regular group member |
| Manager | Administrator |
| Owner | Group Owner |
Paginated retrieval notes:
- For the first retrieval, no need to set
pageTokenin [PagingQueryOption] (not setting, setting null, or setting "" has the same effect). - To retrieve the second page, pass the
pageTokenreturned in the [PagingQueryResult] from the first retrieval.- If it's not "", you can pass this value to retrieve the next page until
pageTokenreturns "", indicating all data has been retrieved. - If it's "", it means there's no next page or retrieval is complete. Passing "" will be treated as retrieving the first page.
- If it's not "", you can pass this value to retrieve the next page until
Code Example
{
//...
// Pagination parameter (setting null or "" has the same effect)
String pageToken = "";
getGroupMembersByRole(pageToken);
//...
}
public void getGroupMembersByRole(String pageToken) {
// Group ID
String groupId = "groupId";
// The role parameter specifies retrieving all role types of group members
GroupMemberRole role = GroupMemberRole.Undef;
// Pagination request parameter
PagingQueryOption option = new PagingQueryOption();
// Set page size, valid range [1~100].
option.setCount(20);
// Pagination token
option.setPageToken(pageToken);
// Sort by join time: true for ascending, false for descending.
option.setOrder(false);
RongCoreClient.getInstance().getGroupMembersByRole(groupId, role, option, new IRongCoreCallback.PageResultCallback<GroupMemberInfo>() {
@Override
public void onSuccess(PagingQueryResult<GroupMemberInfo> result) {
if (!TextUtils.isEmpty(result.getPageToken())) {
// Use the returned pageToken to retrieve the next page
getGroupMembersByRole(result.getPageToken());
} else {
// Retrieval complete
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Retrieval failed
}
});
}
Retrieve Group Member Information
You can use [getGroupMembers] to retrieve group member information for specified users in a specified group.
This interface supports batch retrieval - you can pass multiple userId values to retrieve multiple group members at once, with a maximum of 100 users.
If the current user hasn't joined the specified group, group member information cannot be retrieved.
Code Example
// Group ID
String groupId = "groupId";
// Set user ID list to query
List<String> userIdList = new ArrayList<>();
userIdList.add("userId1");
userIdList.add("userId2");
userIdList.add("userId3");
RongCoreClient.getInstance().getGroupMembers(groupId, userIdList, new IRongCoreCallback.ResultCallback<List<GroupMemberInfo>>() {
@Override
public void onSuccess(List<GroupMemberInfo> groupMemberInfos) {
// Retrieval successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Retrieval failed
}
});
Search Group Members by Nickname
You can use [searchGroupMembers] to paginate search for group member information in local groups.
The search prioritizes matching the group member nickname nickname, then the username name. A match in either field will return the result.
This interface doesn't support returning the total count of all group members.
Paginated retrieval notes:
- For the first retrieval, no need to set
pageTokenin [PagingQueryOption] (not setting, setting null, or setting "" has the same effect). - To retrieve the second page, pass the
pageTokenreturned in the [PagingQueryResult] from the first retrieval.- If it's not "", you can pass this value to retrieve the next page until
pageTokenreturns "", indicating all data has been retrieved. - If it's "", it means there's no next page or retrieval is complete. Passing "" will be treated as retrieving the first page.
- If it's not "", you can pass this value to retrieve the next page until
Code Example
{
//...
// Pagination parameter (setting null or "" has the same effect)
String pageToken = "";
searchGroupMembers(pageToken);
//...
}
public void searchGroupMembers(String pageToken) {
// Group ID
String groupId = "groupId";
// Group member nickname, cannot be empty, max 64 characters
String name = "name";
// Pagination request parameter
PagingQueryOption option = new PagingQueryOption();
// Set page size, valid range [1~200].
option.setCount(20);
// Pagination token
option.setPageToken(pageToken);
// Sort by join time: true for ascending, false for descending.
option.setOrder(false);
RongCoreClient.getInstance().searchGroupMembers(groupId, name, option, new IRongCoreCallback.PageResultCallback<GroupMemberInfo>() {
@Override
public void onSuccess(PagingQueryResult<GroupMemberInfo> result) {
if (!TextUtils.isEmpty(result.getPageToken())) {
// Use the returned pageToken to retrieve the next page
searchGroupMembers(result.getPageToken());
} else {
// Retrieval complete
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Retrieval failed
}
});
}
Set Group Member Information
You can use [setGroupMemberInfo] to set group member information for a specified group.
After successful invocation, all group members will receive the onGroupMemberInfoChanged callback for group member information changes.
The memberInfoEditPermission (GroupMemberInfoEditPermission) determines who can modify group member information. Without proper permissions, the call will return an error code.
GroupMemberInfoEditPermission enumeration:
| Enum Value | Description |
|---|---|
| OwnerOrManagerOrSelf | Group owner, administrators, and the current user can modify member information |
| OwnerOrSelf | Group owner and the current user can modify member information |
| Self | Only the current user can modify their own group member information |
Code Example
// Group ID
String groupId = "groupId";
// Group member user ID
String userId = "userId1";
// Group member nickname
String nickname = "nickname";
// Group member additional information
String extra = "Group member additional information";
RongCoreClient.getInstance().setGroupMemberInfo(groupId, userId, nickname, extra, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Group Administrators
Group Administrators
You can add or remove group administrators.
Add Group Administrators
You can use [addGroupManagers] to add group administrators.
After the API call succeeds, all group members will receive the group operation event callback onGroupOperation with the operation type AddManager.
-
Only the group owner can add administrators.
-
The target members must be in the group, and the group owner cannot be set as an administrator.
-
The maximum number of administrators in a group is 10.
Code Example
// Group ID
String groupId = "groupId";
// List of administrator user IDs
List<String> userIds = new ArrayList<>();
userIds.add("userId1");
userIds.add("userId2");
userIds.add("userId3");
RongCoreClient.getInstance().addGroupManagers(groupId, userIds, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Remove Group Administrators
You can use [removeGroupManagers] to remove group administrators.
This API supports batch removal - you can pass multiple userId values to remove up to 10 administrators at once.
After the API call succeeds, all group members will receive the group operation event callback onGroupOperation with the operation type RemoveManager.
- Only the group owner can remove administrators.
Code Example
// Group ID
String groupId = "groupId";
// List of administrator user IDs
List<String> userIds = new ArrayList<>();
userIds.add("userId1");
userIds.add("userId2");
userIds.add("userId3");
RongCoreClient.getInstance().removeGroupManagers(groupId, userIds, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Members I Follow
You can add, remove, or query group members you follow.
Features
-
The maximum number of followed members is 200 per group.
-
Messages from followed members will bypass conversation Do Not Disturb settings and trigger normal notifications.
-
Push notification priority for messages from followed members follows this hierarchy:
- Application-level Do Not Disturb (no push) > Silent message flag in message body > Sender is a followed member > Conversation Do Not Disturb settings.
-
For details about Do Not Disturb, see Do Not Disturb Overview.
-
After successfully adding or removing followed members, the user's other logged-in devices will receive the multi-device sync callback
onGroupFollowsChangedSync.
Add Members I Follow
Use [addGroupFollows] to add members you follow.
This API supports batch addition - you can pass up to 100 userId values at once.
Code Example
// Group ID
String groupId = "groupId";
// List of member user IDs
List<String> userIds = new ArrayList<>();
userIds.add("userId1");
userIds.add("userId2");
userIds.add("userId3");
RongCoreClient.getInstance().addGroupFollows(groupId, userIds, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Remove Members I Follow
Use [removeGroupFollows] to remove members you follow.
This API supports batch removal - you can pass up to 100 userId values at once.
Code Example
// Group ID
String groupId = "groupId";
// List of member user IDs
List<String> userIds = new ArrayList<>();
userIds.add("userId1");
userIds.add("userId2");
userIds.add("userId3");
RongCoreClient.getInstance().removeGroupFollows(groupId, userIds, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Query Members I Follow
Use [getGroupFollows] to query members you follow.
Code Example
// Group ID
String groupId = "groupId";
RongCoreClient.getInstance().getGroupFollows(groupId, new IRongCoreCallback.ResultCallback<List<FollowInfo>>() {
@Override
public void onSuccess(List<FollowInfo> followInfos) {
// Query successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Query failed
}
});