Get Channel List
You can obtain the channel list through multiple methods. Depending on your actual scenario, you can flexibly maintain the channel list of ultra groups using the capabilities provided by the client SDK and 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. If no channel ID is specified when sending messages, the messages will be sent to theRCDefaultchannel. When retrieving historical messages from theRCDefaultchannel, you need to 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 do not belong to any channel. RC supports adjusting services to the latest behavior. This adjustment will affect multiple functionalities including message sending/receiving, conversation retrieval, message history clearing, and muting on both client and server sides. If needed, please submit a ticket to consult detailed solutions.
How to Get the Complete Channel List of an Ultra Group
The complete channel list of 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 create or join up to 50 channels within each ultra group.
The IMLib SDK generates a local ultra group channel list in the database based on messages sent and received in channels. This list only includes channels that have generated messages locally and may not represent the complete channel list of the ultra group.
We recommend maintaining the ultra group channel list from your application's business server. Typically, the application needs to know the ultra groups the current user has joined and their channel lists to implement specific business functionalities. If different users within the same ultra group need to display personalized channel lists (e.g., the app needs to display starred channels in the UI), the ultra group channel list must be saved for each user.
The application server can also group ultra groups as needed (as shown in the UI framework design in the Ultra Group Overview).
Get the Local Channel List of a Specified Ultra Group
The IMLib SDK generates corresponding channel conversations in the local database based on messages sent and received in channels. You can retrieve the channel list generated by the IMLib SDK from the local database. The retrieved channel list is sorted in reverse chronological order.
NSArray *conversationList = [[RCChannelClient sharedChannelManager] getConversationListForAllChannel:ConversationType_ULTRAGROUP targetId:self.ultraGroup.groupId];
for (RCConversation *conversation in conversationList) {
NSString *totalCountInfo = [NSString stringWithFormat:@"Unread count: %d",conversation.unreadMessageCount]
NSString *totalMentionCountInfo = [NSString stringWithFormat:@"Total unread mentions: %d",conversation.mentionedCount]
/// since 5.4.5
NSString *mentionMeCountInfo = [NSString stringWithFormat:@"Unread mentions of me: %d",conversation.mentionedMeCount]
}
Get the Local Channel List of a Specified Type in an Ultra Group
The IMLib SDK has supported retrieving channel lists by type since version 5.2.4.
The IMLib SDK generates corresponding channel conversations in the local database based on messages sent and received in channels. You can retrieve the channel list generated by the IMLib SDK from the local database. The retrieved channel list is sorted in reverse chronological order.
Channel Type (channelType) supports public or private channels in ultra groups.
Interface Prototype
/*!
Retrieve the list of public or private channels for a specified ultra group locally
@param targetId Conversation ID
@param channelType Channel type
@param successBlock Success callback [Conversation list]
@param errorBlock Failure callback [status: Error code for failure]
@remarks Ultra group message operations
*/
- (void)getUltraGroupChannelList:(NSString *)targetId
channelType:(RCUltraGroupChannelType)channelType
success:(nullable void (^)(NSArray<RCConversation *>* list))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;
Parameter Description
-
Channel Type (
channelType)typedef NS_ENUM(NSInteger, RCUltraGroupChannelType) {
/*!
Ultra group public channel
*/
RCUltraGroupChannelTypePublic = 0,
/*!
Ultra group private channel
*/
RCUltraGroupChannelTypePrivate = 1
};