Group member list
Chat UI SDK supports two approaches for displaying user information:
- User information provider delegate (this document): You must actively retrieve user information, group information, and group member user information from your app server and provide it to the SDK. The user nickname and avatar passed when registering to obtain a token from the Nexconn server are used only for push notifications.
- [User information managed approach]: Chat UI SDK supports switching to the managed information approach to display user and group information in the channel page and channel list.
This document describes how your application provides group member data to the Chat UI SDK. This data is used in the default member picker that appears when you type the @ symbol in a group channel, and in the member picker for initiating group audio/video calls. After configuration, the Chat UI SDK displays group member avatars, usernames, and in-group display names wherever group member lists are needed.
The group member callback returns UserInfo, which is provided by Chat SDK (ai.nexconn.chat:chat) and used by Chat UI. Use matching chat and chatui versions, especially when integrating local AAR files such as nexconn-chat_<version>.aar and nexconn-chatui_<version>.aar.
Understand the group member provider interface
The SDK defines the group member provider (IGroupMembersProvider) in the NCMentionManager class. When the Chat UI SDK needs to display a group member list, it triggers the getGroupMembers method of IGroupMembersProvider to retrieve group member information from your application.
You must implement the IGroupMembersProvider and IGroupMemberCallback interfaces of NCMentionManager for the SDK to obtain your app's group member data. If the SDK cannot retrieve group members, the member picker displays an empty list.
public interface IGroupMembersProvider {
void getGroupMembers(String groupId, IGroupMemberCallback callback);
}
public interface IGroupMemberCallback {
void onGetGroupMembersResult(List<UserInfo> members);
}
Set the group member provider
After initialization, call NCMentionManager.getInstance().setGroupMembersProvider(...) to set the group member information provider. You must actively retrieve the group member data required by the SDK from your application layer, such as your app server.
When the Chat UI SDK needs to display a group member list, the SDK triggers the getGroupMembers callback and provides the group ID. In this method, you can use the group ID to retrieve the user IDs within the group, query user information from your application layer based on those user IDs, and then provide the UserInfo list to the SDK through IGroupMemberCallback.
If your app implements a group member user information provider, you can use it to retrieve group member display names. See Group member user information for details.
NCMentionManager.getInstance().setGroupMembersProvider(new NCMentionManager.IGroupMembersProvider() {
@Override
public void getGroupMembers(String groupId, NCMentionManager.IGroupMemberCallback iGroupMemberCallback) {
// groupId is the group ID. Use it to retrieve user IDs within the group, then get user information and return it.
// Example code:
List<UserInfo> list = new ArrayList<>();
UserInfo userInfo = new UserInfo("userid1", 0, "Alice", "https://example.com/avatar.png");
...
list.add(userInfo);
// Add more members as needed.
iGroupMemberCallback.onGetGroupMembersResult(list); // Call the callback's onGetGroupMembersResult to return group information
}
});