Managing group members
This document guides developers on how to use RC Web IMLib SDK to implement features like setting or querying group member profiles, adding or removing group administrators.
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.
Group Member Profile Change Callback
After calling the setGroupMemberInfo method to set group member information, all group members will receive the Events.GROUP_MEMBER_INFO_CHANGED
callback for profile changes.
- Event listeners should be registered globally and only once to avoid duplicate notifications.
- The callback data type is IGroupMemberInfoChanged
Example Code
RongIMLib.addEventListener(Events.GROUP_MEMBER_INFO_CHANGED, (data) => {
console.log('Group member profile change callback', data);
});
Paginated Group Member Query
Call getGroupMembersByRole to paginate group members by role. Refer to GroupMemberRole for role types.
The Web version's IPagingQueryResult structure currently doesn't include the totalCount field.
Interface
RongIMLib.getGroupMembersByRole(groupId, role, option)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID. |
role | GroupMemberRole | Yes | Member role. Set to GroupMemberRole.UNDEF to query all members regardless of role. |
option | IPagingQueryOption | Yes | Pagination parameters. Maximum 100 records per page. |
- For initial query,
pageToken
can be omitted or set to''
(equivalent). - For subsequent pages, use the
pageToken
from previous response:
- Non-empty
pageToken
indicates more data available. - Empty
pageToken
means all data has been retrieved.
Example Code
const groupId = 'group001';
const role = RongIMLib.GroupMemberRole.UNDEF;
const option = {
count: 50, // Required, range 1-100
}
const res = await RongIMLib.getGroupMembersByRole(groupId, role, option);
console.info('Paginated group member query', res);
// Fetch next page
if (res && res.pageToken) {
const nextRes = await RongIMLib.getGroupMembersByRole(groupId, role, {
...option,
pageToken: res.pageToken
});
console.info('Paginated group member query - next page', nextRes);
}
Get Group Member Information
Call getGroupMembers to retrieve detailed information for specified group members.
Interface
RongIMLib.getGroupMembers(groupId, userIds)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID. |
userIds | string[] | Yes | User ID array (max 100). |
- Non-group members cannot query member information.
- Only returns existing group members (non-members in
userIds
are filtered out).
Example Code
const groupId = 'group001';
const userIds = ['user01']; // Returns [] if user01 isn't in group001
const res = await RongIMLib.getGroupMembers(groupId, userIds);
console.info('Get group member information', res);
Search Group Members by Nickname (Electron Only)
Electron platform only (not supported on Web).
Call searchGroupMembers to paginate local group member searches.
- Prioritizes nickname matches, falls back to username if nickname is empty.
- Returns member if either field matches.
Interface
RongIMLib.searchGroupMembers(groupId, name, option)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID. |
name | string | Yes | Search term (fuzzy match, 64 char max, no empty/whitespace). |
option | IPagingQueryOption | Yes | Pagination parameters (max 100 records/page). |
Example Code
const groupId = 'group001';
const name = 'name'; // Non-empty, max 64 chars
const option = {
count: 50, // Required, range 1-100
}
const res = await RongIMLib.searchGroupMembers(groupId, name, option);
console.info('Search group members by nickname', res);
// Fetch next page
if (res && res.pageToken) {
const nextRes = await RongIMLib.searchGroupMembers(groupId, name, {
...option,
pageToken: res.pageToken
});
console.info('Search group members - next page', nextRes);
}
Set Group Member Information
Call setGroupMemberInfo to configure group member profiles.
- After successful execution, all group members will receive the Events.GROUP_MEMBER_INFO_CHANGED notification for profile changes.
- The
memberInfoEditPermission
setting in GroupMemberInfoEditPermission determines whether group member profiles can be modified. Operation will fail with error code if permission is denied.
Interface
RongIMLib.setGroupMemberInfo(groupId, userId, nickname, extra)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID |
userId | string | Yes | Group member user ID |
nickname | string | Yes | Member nickname (max 64 characters, cannot be blank spaces) |
extra | string | No | Additional member info (max 128 characters) |
Example
const groupId = 'group001'; // Group ID
const userId = 'user01'; // Member user ID
const nickname = 'nickname'; // Member nickname (max 64 chars, no blank spaces)
const extra = 'extra info'; // Optional additional info (max 128 chars)
const res = await RongIMLib.setGroupMemberInfo(groupId, userId, nickname, extra);
console.info('Group member profile update result', res);
return res;
Group Administrators
Add or remove group administrators.
Add Group Administrators
Call addGroupManagers to add group administrators.
- Only group owners can call this method
- Maximum 10 administrators per group
- Successful addition triggers Events.GROUP_OPERATION callback (operation=5/GroupOperation.ADD_MANAGER) for all members
Interface
RongIMLib.addGroupManagers(groupId, userIds)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | String | Yes | Group ID |
userIds | string[] | Yes | User ID array (must be existing members, max 10 per operation) |
Example
const groupId = 'group001'; // Group ID
const userIds = ['user001', 'user002']; // User IDs (must be members, max 10)
const res = await RongIMLib.addGroupManagers(groupId, userIds);
console.info('Add administrators result', res);
Remove Group Administrators
Call removeGroupManagers to remove administrators.
Successful removal triggers Events.GROUP_OPERATION callback (operation=6/GroupOperation.REMOVE_MANAGER) for all members
Interface
RongIMLib.removeGroupManagers(groupId, userIds)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | String | Yes | Group ID |
userIds | Array | Yes | User ID array (max 10 per operation) |
Example
const groupId = 'group001'; // Group ID
const userIds = ['user001', 'user002']; // User IDs (max 10 per operation)
const res = await RongIMLib.removeGroupManagers(groupId, userIds);
console.info('Remove administrators result', res);
Members I Follow
Add, remove, or query specially followed group members.
Features
- Maximum 200 followed members per group
- Messages from followed members bypass conversation mute settings
- Push notification priority hierarchy:
- Application-level Do Not Disturb >
- Silent message flag >
- Followed member status >
- Conversation mute settings (See Do Not Disturb Overview)
- Changes trigger multi-device sync via Events.GROUP_FOLLOWS_CHANGED_SYNC
Followed Members Sync Callback
Triggered on other devices when followed member settings change.
- Register event listener globally once to avoid duplicate callbacks
- Callback data type: IGroupFollowsChangedSync
Example
RongIMLib.addEventListener(Events.GROUP_FOLLOWS_CHANGED_SYNC, (data) => {
console.log('Followed members sync callback', data);
});
Add Followed Members
Call addGroupFollows to add specially followed members.
Maximum 200 followed members per group
Interface
RongIMLib.addGroupFollows(groupId, userIds)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID |
userIds | string[] | Yes | User ID array (max 100 per operation) |
Example
const groupId = 'group001'; // Group ID
const userIds = ['user001', 'user002']; // User IDs (max 100 per operation)
const res = await RongIMLib.addGroupFollows(groupId, userIds);
console.info('Add followed members result', res);
Remove Followed Members
Call removeGroupFollows to remove followed members.
Interface
RongIMLib.removeGroupFollows(groupId, userIds)
Sample code
const groupId = 'group001'; // Group ID
const userIds = ['user001', 'user002']; // User IDs (max 100 per operation)
const res = await RongIMLib.removeGroupFollows(groupId, userIds);
console.info('Remove followed members result', res);
Get Followed Group Members
Call getGroupFollows to query followed group members.
Interface
RongIMLib.getGroupFollows(groupId)
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
groupId | string | Yes | Group ID |
Sample code
const groupId = 'group001'; // Group ID
const res = await RongIMLib.getGroupFollows(groupId);
console.info('Get followed members result', res);