Group Information
IMKit supports two user profile display modes:
- User Info Provider Delegate Mode (current documentation): The app developer must actively fetch user profiles, group information, and group member profiles from the application server and provide them to the SDK. The nickname and avatar registered with RC server during token acquisition are only used for push notifications.
- [User Profile Hosting Mode]: Starting from v5.12.0, IMKit allows switching to hosted profiles for displaying user/group information 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 display purposes.
- User profiles: Includes nickname and avatar
- Group information: Includes group name and group avatar
- Group member profiles: Only supports group member nicknames
This document specifically describes how the application layer (App) provides group information (Group) to IMKit SDK for displaying group avatars (not member avatars) and group names in IMKit UIs.
Refresh Group Information
If the App locally maintains group information data, it can directly refresh the cached and database-stored group information (group name and avatar). After refreshing, IMKit UI will display the latest Group information.
Group information refresh must be performed after IMKit successfully establishes an IM connection; otherwise, local data cannot be updated.
Potential use cases include:
- After the App's first launch and successful IM connection, bulk-provide user information required by the business to the SDK, which will write it to cache and local database for future use.
- After IM connection is established, if group names/avatars change (e.g., notified by the app server via messages), the client calls the interface to refresh group information.
Group group = new Group(groupId, groupName, groupPortrait);
RongUserInfoManager.getInstance().refreshGroupInfoCache(group);
If the App doesn’t maintain local data, we recommend dynamically providing group information when IMKit needs to display it.
Dynamically Provide Group Information
Starting from IMKit v5.X, the SDK introduced the Group Info Provider interface (UserDataProvider.GroupInfoProvider). If IMKit cannot retrieve group names/avatars from RongUserInfoManager
, it triggers the getGroupInfo
callback. The App should implement this callback to provide the required group name and avatar.
After obtaining the data, the SDK automatically updates group names/avatars and refreshes the UI.
Set Group Info Provider to Supply Data to SDK
In IMKit, use the setGroupInfoProvider method of RongUserInfoManager
to configure the provider. This must be set after SDK initialization but before IM connection. We recommend setting it once during the app lifecycle.
If the SDK has previously obtained group information (with isCacheGroupInfo
set to true
), it caches the data in memory. The SDK prioritizes local database queries, making the data available on subsequent app launches. The default SDK behavior is as follows:
- When group information is needed for UI display, the SDK first checks memory cache.
- If cached or locally stored data exists, the SDK directly returns it to the UI layer for refresh.
- If no local data is found, the SDK triggers the UserDataProvider.GroupInfoProvider callback to fetch data from the app layer, then refreshes the UI.
We recommend setting isCacheGroupInfo
to true
to enable persistent local storage of group information.
Implement the getGroupInfo
callback in UserDataProvider.GroupInfoProvider to supply data:
-
Asynchronous Fetch with Manual Refresh: Prevents UI blocking during time-consuming operations.
- Have
getGroupInfo
returnnull
while triggering async logic to fetch group info for thegroupId
. This temporarily sets the group info to empty.
Parameters
Parameter Type Description groupProvider UserDataProvider.GroupInfoProvider Group info provider interface isCacheGroupInfo boolean Whether to persistently store group info in SDK's local database ( true
= store).Sample Code
RongUserInfoManager.getInstance().setGroupInfoProvider(new UserDataProvider.GroupInfoProvider() {
@Override
public Group getGroupInfo(String groupId) {
...// IMKit calls getGroupInfo per groupId when displaying group info (e.g., conversation list/chat UI)
// Implement async group info fetching logic here, then provide data via refreshGroupInfoCache
return null;
}
}, true);- After successfully obtaining group info, call
refreshGroupInfoCache
to manually update the data. The SDK will refresh the UI. See Refresh Group Information.
Group group = new Group(groupId, groupName, groupPortrait);
RongUserInfoManager.getInstance().refreshGroupInfoCache(group); - Have
-
Synchronous Return: Directly return the
groupId
's group info. The SDK refreshes the UI upon receipt.RongUserInfoManager.getInstance().setGroupInfoProvider(new UserDataProvider.GroupInfoProvider() {
@Override
public Group getGroupInfo(String groupId) {
Group group = new Group(groupId, groupName, groupPortrait);
return group;
}
}, true);
Retrieve Group Information
Apps can actively call getGroupInfo
from RongUserInfoManager
to fetch group info. The SDK behavior:
- First attempts to retrieve app-provided data from local cache. If
isCacheGroupInfo
wastrue
, also checks the local database. - If no local data exists, triggers the
UserInfoProvider
'sgetGroupInfo
callback. If implemented, the SDK obtains the Group data.
Group group = RongUserInfoManager.getInstance().getGroupInfo(groupId);