Query Chatroom Information
Retrieve chatroom information, which can return the following data:
- Total number of chatroom members
- A list of a specified number (up to 20) of chatroom members, including the member's user ID and the time they joined the chatroom
tip
Rate Limit: A single device can call this API once per second, with a maximum of 20 calls per minute per device.
You can use the getChatRoomInfo
method under RCIMClient
or RCChatRoomClient
:
[[RCIMClient sharedRCIMClient] getChatRoomInfo:@"chatroomId"
count:0
order:RC_ChatRoom_Member_Asc
success:^(RCChatRoomInfo *chatRoomInfo) {
// Get ChatRoomInfo properties
NSString *targetId = chatRoomInfo.targetId;
int totalMemberCount = chatRoomInfo.totalMemberCount;
NSArray<RCChatRoomMemberInfo *> *memberInfoArray = chatRoomInfo.memberInfoArray;
// Get ChatRoomMemberInfo properties
for (RCChatRoomMemberInfo *memberInfo in memberInfoArray) {
NSString *userId = memberInfo.userId;
long long joinTime = memberInfo.joinTime;
// TODO
}
}
error:^(RCErrorCode status) {
// Handle error
}];
Parameter | Type | Description |
---|---|---|
targetId | NSString | The chatroom ID. The maximum valid length is 64 characters. |
count | int | The number of chatroom members to retrieve. Range: 0-20. Due to the large number of members in chatrooms, the maximum number of members that can be retrieved is 20 to balance efficiency and user experience. If count is 0, the returned chatroom information will only include the total number of members, not the specific member list. |
order | RCChatRoomMemberOrder | The order in which the member list is retrieved (either the earliest or latest joined members). RC_ChatRoom_Member_Asc (1 ) indicates ascending order, retrieving members from the earliest joined in ascending order of join time; RC_ChatRoom_Member_Desc (2 ) indicates descending order, retrieving members from the latest joined in descending order of join time. |
successBlock | Block | Callback for successful retrieval. Returns RCChatRoomInfo, which contains the chatroom member list as requested. See the RCChatRoomInfo Class Description below for details. |
errorBlock | Block | Callback for failure. status returns the error code RCErrorCode. |
-
RCChatRoomInfo Class Description:
Parameter Type Description targetId NSString Chatroom information memberOrder RCChatRoomMemberOrder The order in which the member list is retrieved memberInfoArray NSArray Chatroom member list, where each element is a chatroom member object RCChatRoomMemberInfo, containing the user ID ( userId
) and the join time (joinTime
) in Unix timestamp format, in milliseconds. The members in the list are ordered from oldest to newest by join time.totalMemberCount int The total number of members in the current chatroom