Skip to main content

Group Member User Information

tip

IMKit supports two user information display methods:

  • User Information Provider Proxy (current documentation): App developers must actively obtain user profiles, group information, and group member details from the application server and provide them to the SDK. The user nickname and avatar registered with RC server during token acquisition are only used for push notification services.
  • [User Profile Hosting]: Starting from version 5.12.0, IMKit allows switching to hosted user information for displaying user/group details in chat UIs and conversation lists.

IMKit uses the RongUserInfoManager class to uniformly manage the following data. Apps must provide this data to IMKit via RongUserInfoManager for UI presentation.

  • User Information: Includes nickname and avatar.
  • Group Information: Includes group name and group avatar.
  • Group Member Information: Only supports group-specific nicknames.

This document focuses on how the application layer (App) provides group member nicknames and avatars (GroupUserInfo) to IMKit SDK.

Refresh Group Member Information

If the App maintains local group member data (e.g., group nicknames), it can directly refresh the cached and database-stored group member information. After refreshing, IMKit UI will display the updated GroupUserInfo.

Group member information can only be refreshed after IMKit successfully establishes an IM connection. Typical use cases include:

  • After initial App launch and successful IM connection, bulk-provide all required group member information to the SDK for caching and local database storage.
  • When group member nicknames change post-connection (e.g., via server notifications), call this interface to update information.
RongUserInfoManager.getInstance().refreshGroupUserInfoCache(groupUserInfo);

For Apps without local data, dynamically provide group member information when IMKit requires it for display.

Dynamic Provision of Group Member Information

Starting from IMKit 5.X, the SDK introduces the UserDataProvider.GroupUserInfoProvider interface. When IMKit cannot retrieve group member information from RongUserInfoManager, it triggers the getGroupUserInfo callback. Apps should implement this callback to supply group member nicknames.

Upon receiving the data, SDK automatically configures group-specific nicknames and updates relevant UIs.

Set Group Member Information Provider

Call RongUserInfoManager's setGroupUserInfoProvider method after App initialization but before establishing IM connection.

If SDK has previously obtained group member information with persistent storage enabled (isCacheGroupInfo set to true), it caches the data in memory. The SDK prioritizes local database queries, making the information available across App restarts. Default SDK behavior:

  1. When displaying group member information, SDK first checks memory cache.
  2. If data exists in cache/database, SDK directly renders it in UI.
  3. If no local data exists, SDK triggers UserDataProvider.GroupUserInfoProvider's callback to fetch information from the App layer, then refreshes UI.
tip

Set isCacheGroupUserInfo to true to enable persistent storage of group member information.

Implement the getGroupUserInfo callback to provide group member details:

  • Asynchronous Fetch with Manual Refresh: Prevents UI blocking during time-consuming operations.

    1. Return null in getGroupUserInfo while initiating asynchronous data retrieval logic. Note: This temporarily sets the group nickname to empty.
    RongUserInfoManager.getInstance().setGroupUserInfoProvider(new UserDataProvider.GroupUserInfoProvider() {
    @Override
    public GroupUserInfo getGroupUserInfo(String groupId, String userId) {
    ... // SDK calls getGroupUserInfo when displaying group info (e.g., conversation list/chat UI).
    // Implement async data fetching here, then provide results via refreshGroupUserInfoCache.
    return null;
    }
    }, true);
    1. After successful data retrieval, call refreshGroupUserInfoCache to update nicknames. See Refresh Group Member Information.
  • Synchronous Return: Directly return group member information for immediate UI updates.

    RongUserInfoManager.getInstance().setGroupUserInfoProvider(new UserDataProvider.GroupUserInfoProvider() {
    @Override
    public GroupUserInfo getGroupUserInfo(String groupId, String userId) {
    GroupUserInfo groupUserInfo = new GroupUserInfo(groupId, userId, "Xiaohua");
    return groupUserInfo; // Synchronously return group nickname.
    }
    }, true);

Retrieve Group Member Information

Apps can actively fetch group member information via RongUserInfoManager's getGroupUserInfo method. SDK behavior:

  1. First attempts to retrieve App-provided data from local cache. If persistent storage was enabled (isCacheGroupUserInfo = true), SDK also queries local database.
  2. If no local data exists, SDK triggers GroupUserInfoProvider's callback to obtain GroupUserInfo.
GroupUserInfo groupUserInfo = RongUserInfoManager.getInstance().getGroupUserInfo(groupId, userId);
ParameterTypeDescription
groupIdStringGroup ID
userIdStringUser ID