Get Channel List
You have multiple ways to obtain the channel list. Based on your actual requirements, you can flexibly maintain ultra group channel lists using capabilities provided by either the client SDK or RC server API.
- If your application/environment enabled ultra group services on or after October 13, 2022, the ultra group service will include a default channel with ID
RCDefault. When sending messages without specifying a channel ID, the messages will be sent to theRCDefaultchannel. To retrieve historical messages from theRCDefaultchannel, you must pass this channel ID. - If your application/environment enabled ultra group services before October 13, 2022, messages sent without specifying a channel ID will not belong to any channel. When retrieving historical messages without passing a channel ID, you can obtain messages that don't belong to any channel. RC supports adjusting services to adopt the latest behavior. This adjustment will affect multiple functionalities including message sending/receiving, conversation retrieval, history clearing, and muting across both client and server. If needed, please submit a ticket to consult detailed solutions.
How to Get the Complete Ultra Group Channel List
The complete list of channels under an ultra group can be obtained through the RC server API (/ultragroup/channel/get.json).
Note that a single user can join up to 100 ultra groups, and within each ultra group, they can join or create up to 50 channels.
The IMLib SDK generates a local ultra group channel list in the database based on messages sent/received in channels. This list only includes channels where local message activity has occurred and may not represent the complete channel list of the ultra group.
We recommend maintaining ultra group channel lists from your application's business server. Typically, applications need to track which ultra groups a user has joined and their corresponding channel lists to implement specific business features. If different users within the same ultra group require personalized channel lists (e.g., displaying user-starred channels in the UI), you'll need to store ultra group channel lists per user.
The application server can also categorize ultra groups as needed (as shown in the UI framework design within Ultra Group Overview).
Get Local Channel List for a Specified Ultra Group
The IMLib SDK generates corresponding channel conversations in the local database based on messages sent/received in channels. You can retrieve the channel list generated by IMLib SDK from the local database. The returned channel list is sorted in reverse chronological order.
Sample Code
ChannelClient.getInstance()
.getConversationListForAllChannel(
Conversation.ConversationType.ULTRA_GROUP,
groupId,
new IRongCoreCallback.ResultCallback<List<Conversation>>() {
@Override
public void onSuccess(List<Conversation> conversations) {
if (conversations == null) return;
for (Conversation conversation : conversations) {
//Get unread message count for the conversation
int unreadMessageCount = conversation.getUnreadMessageCount();
//Get unread mention count for the conversation
int unreadMentionedCount =
conversation.getUnreadMentionedCount();
//Get unread mentions targeting me count for the conversation @since 5.4.5
int mentionedMeCount = conversation.getUnreadMentionedMeCount();
}
//This callback returns in a non-UI thread. Switch to UI thread if UI operations are needed.
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode e) {}
});
Get Local Channel List of Specified Type for an Ultra Group
SDK supports fetching channel lists by type starting from version 5.2.4.
The IMLib SDK generates corresponding channel conversations in the local database based on messages sent/received in channels. You can retrieve the channel list generated by IMLib SDK from the local database. The returned channel list is sorted in reverse chronological order:
Channel Type (channelType) supports ultra group public channels or private channels.
Interface
/**
* Get ultra group channel list
*
* @param targetId Ultra group ID
* @param channelType Channel type
* @param callback Result callback
*/
public abstract void getUltraGroupChannelList(
String targetId,
IRongCoreEnum.UltraGroupChannelType channelType,
IRongCoreCallback.ResultCallback<List<Conversation>> callback);
Parameter Description
-
Channel Type (
channelType)/** Ultra group channel types Added from version 5.2.4 */
public enum UltraGroupChannelType {
/** Ultra group public channel */
ULTRA_GROUP_CHANNEL_TYPE_PUBLIC,
/** Ultra group private channel */
ULTRA_GROUP_CHANNEL_TYPE_PRIVATE;
}