Group member management
This document guides developers on how to use RC's IMLib SDK to set or query group member profiles, add or remove group administrators, and other related functions.
This feature is supported starting from version 5.12.0.
Enabling the Service
Before using this feature, you must enable the profile hosting service by submitting a ticket.
Group members
You can query members of a specified group or set group member information.
Get group member information by page
Use getGroupMembersByRole to get group member information by role in pages.
This interface supports returning the total count matching the query conditions, 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 |
Pagination instructions:
- For the first pull, no need to set
pageToken
in PagingQueryOption (not setting, setting null, or setting "" have the same effect). - To pull the second page, pass the
pageToken
from the first pull result PagingQueryResult.- If not "", you can pass this value to pull again until
pageToken
returns "", indicating completion. - If "", means no more pages or pulling is complete. Passing "" will be treated as pulling the first page.
- If not "", you can pass this value to pull again 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 pulling group member information of all role types
GroupMemberRole role = GroupMemberRole.Undef;
// Pagination request parameters
PagingQueryOption option = new PagingQueryOption();
// Set page size, range [1~100].
option.setCount(20);
// Pagination parameter
option.setPageToken(pageToken);
// Get by join time in ascending/descending order. true: ascending; false: 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 pull the next page
getGroupMembersByRole(result.getPageToken());
} else {
// Pulling complete
}
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Pull failed
}
});
}
Get group member information
Use getGroupMembers to get specified group member information for specified users.
This interface supports batch retrieval - you can pass multiple userId
s to get multiple group member information at once, up to 100.
If the current user hasn't joined the specified group, group member information cannot be obtained.
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) {
// Pull successful
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Pull failed
}
});
Search group members by nickname
Use searchGroupMembers to search for group member information of specified groups locally in pages.
The search first matches group member nickname nickname
, then group member username name
. A match in either field returns the result.
This interface doesn't support returning the total count of all group members.
Pagination instructions:
- For the first pull, no need to set
pageToken
in PagingQueryOption (not setting, setting null, or setting "" have the same effect). - To pull the second page, pass the
pageToken
from the first pull result PagingQueryResult.- If not "", you can pass this value to pull again until
pageToken
returns "", indicating completion. - If "", means no more pages or pulling is complete. Passing "" will be treated as pulling the first page.
- If not "", you can pass this value to pull again 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 parameters
PagingQueryOption option = new PagingQueryOption();
// Set page size, range [1~200].
option.setCount(20);
// Pagination parameter
option.setPageToken(pageToken);
// Get by join time in ascending/descending order. true: ascending; false: 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 pull the next page
searchGroupMembers(result.getPageToken());
} else {
// Pulling complete
}
}
Set group member information
You can use setGroupMemberInfo to set group member information for a specified group.
After the API call succeeds, all group members will receive the onGroupMemberInfoChanged
callback for group member information changes.
The group member information update permission memberInfoEditPermission
(GroupMemberInfoEditPermission
) determines whether group member information can be modified. If you don't have permission, the call will return an error code.
GroupMemberInfoEditPermission
enum description:
Enum Value | Group Member Role |
---|---|
OwnerOrManagerOrSelf | Group Owner, Group Administrator, and current user can modify member information in the group |
OwnerOrSelf | Only Group Owner and current user can modify member information in the group |
Self | Only 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 extra information
String extra = "Group member extra information";
RongCoreClient.getInstance().setGroupMemberInfo(groupId, userId, nickname, extra, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
// Operation succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Group Administrator
You can add or remove group administrators.
Add group administrator
You can use addGroupManagers to add group administrators.
After the API call succeeds, all group members will receive the onGroupOperation
callback for group operations, with the operation type being AddManager
.
- Only the Group Owner can add group administrators.
- The member to be set must be in this 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";
// Administrator user ID list
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 succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Remove group administrator
You can use removeGroupManagers to remove group administrators.
This API supports batch removal. You can pass multiple userIds
to remove multiple group administrators at once, with a maximum of 10.
After the API call succeeds, all group members will receive the onGroupOperation
callback for group operations, with the operation type being RemoveManager
.
- Only the Group Owner can remove group administrators.
Code example
// Group ID
String groupId = "groupId";
// Administrator user ID list
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 succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Members I Follow
You can add, remove, or query group members you follow.
Feature description
- The maximum number of Members I Follow is 200.
- Messages sent by Members I Follow in this group are not affected by Conversation Do Not Disturb settings and will trigger normal notifications.
- Push notification priority for messages sent by Members I Follow:
- Application-level Do Not Disturb status set to no push > Message marked as Silent Message in message body > Sender is a Member I Follow > Conversation Do Not Disturb settings.
- For details about Do Not Disturb, see Do Not Disturb Overview.
- After successfully setting or removing Members I Follow, the user's other logged-in devices will receive the multi-device sync callback
onGroupFollowsChangedSync
for friend information changes.
Add Members I Follow
You can use addGroupFollows to add Members I Follow.
This API supports batch addition. You can pass multiple userIds
to add multiple Members I Follow at once, with a maximum of 100.
Code example
// Group ID
String groupId = "groupId";
// Group member user ID list
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 succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Remove Members I Follow
You can use removeGroupFollows to remove Members I Follow.
This API supports batch removal. You can pass multiple userIds
to remove multiple Members I Follow at once, with a maximum of 100.
Code example
// Group ID
String groupId = "groupId";
// Group member user ID list
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 succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Operation failed
}
});
Query Members I Follow
You can use getGroupFollows to query Members I Follow.
Code example
// Group ID
String groupId = "groupId";
RongCoreClient.getInstance().getGroupFollows(groupId, new IRongCoreCallback.ResultCallback<List<FollowInfo>>() {
@Override
public void onSuccess(List<FollowInfo> followInfos) {
// Pull succeeded
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {
// Pull failed
}
});