Group Query
This document guides developers on using RC IM IMLib SDK to implement functions such as retrieving joined groups and obtaining specific group information.
This feature is supported starting from version 5.12.0.
Enabling the Service
Before using this feature, you must enable the profile hosting service by submitting a ticket.
Group Query
Get Group Information
You can call the getGroupsInfo
method to retrieve group information.
- This method prioritizes local lookup. When the user is not in the group, it will fetch the latest group information from the server only if the local cache doesn't exist or is older than 10 minutes.
- A single call supports retrieving information for up to 20 groups, with a maximum of 5 queries per second.
Method Signature
- (void)getGroupsInfo:(NSArray<NSString *> *)groupIds
success:(void (^)(NSArray<RCGroupInfo *> *groupInfos))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupIds | NSArray | List of targetIds for groups to query (max 20 per call) |
successBlock | Block | Success callback returning an array of RCGroupInfo objects |
errorBlock | Block | Failure callback |
Example Code
[[RCCoreClient sharedCoreClient] getGroupsInfo:@[@"groupId1", @"groupId2"]
success:^(NSArray<RCGroupInfo *> * _Nonnull groupInfos) {
// Success
}
error:^(RCErrorCode errorCode) {
// Failure
}
];
Get Joined Group Information
Use getJoinedGroups
to retrieve information for groups the current user has joined.
This batch operation supports querying up to 20 groups at once.
Method Signature
- (void)getJoinedGroups:(NSArray<NSString *> *)groupIds
success:(void (^)(NSArray<RCGroupInfo *> *groupInfos))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupIds | NSArray | List of targetIds for joined groups (max 20 per call) |
successBlock | Block | Success callback returning an array of RCGroupInfo objects |
errorBlock | Block | Failure callback |
Example Code
NSArray *groupIds = @[@"groupId1", @"groupId2"];
[[RCCoreClient sharedCoreClient] getJoinedGroups:groupIds success:^(NSArray<RCGroupInfo *> * _Nonnull groupInfos) {
// Success
} error:^(RCErrorCode errorCode) {
// Failure
}];
Get Joined Groups by Role
Use getJoinedGroupsByRole
to paginate through joined groups filtered by member role.
The success callback's result
includes the total count of matching groups.
Method Signature
- (void)getJoinedGroupsByRole:(RCGroupMemberRole)role
option:(RCPagingQueryOption *)option
success:(void (^)(RCPagingQueryResult<RCGroupInfo *> *result))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
role | RCGroupMemberRole | Group member role |
option | RCPagingQueryOption | Pagination options including page token (optional), page size (max 100), and sort order (default descending) |
successBlock | Block | Success callback returning RCPagingQueryResult with group data |
errorBlock | Block | Failure callback |
Type: RCGroupMemberRole
Enum Value | Role Description |
---|---|
RCGroupMemberRoleUndef | Undefined role (queries all member types) |
RCGroupMemberRoleNormal | Regular group member |
RCGroupMemberRoleManager | Administrator |
RCGroupMemberRoleOwner | Group Owner |
Type: RCPagingQueryOption
Parameter | Type | Description |
---|---|---|
pageToken | NSString | Pagination token. Pass nil or @"" for first page. Subsequent calls should use the token returned in result.pageToken until empty string indicates completion. |
count | NSInteger | Page size (max 200) |
order | BOOL | Sort by join time (NO for descending, YES for ascending) |
Example Code
- (void)getJoinedGroupsByRole:(NSString *)pageToken {
RCGroupMemberRole role = RCGroupMemberRoleUndef;
RCPagingQueryOption *option = [[RCPagingQueryOption alloc] init];
option.pageToken = pageToken;
option.count = 20;
option.order = NO;
[[RCCoreClient sharedCoreClient] getJoinedGroupsByRole:role option:option
success:^(RCPagingQueryResult<RCGroupInfo *> * _Nonnull result) {
if (result.pageToken.length > 0) {
[self getJoinedGroupsByRole:result.pageToken];
} else {
// All data retrieved
}
} error:^(RCErrorCode errorCode) {
// Failure
}];
}
Method signature
- (void)searchJoinedGroups:(NSString *)groupName
option:(RCPagingQueryOption *)option
success:(void (^)(RCPagingQueryResult<RCGroupInfo *> *result))successBlock
error:(void (^)(RCErrorCode errorCode))errorBlock;
Parameters
Parameter | Type | Description |
---|---|---|
groupName | NSString | Group name (required), maximum 64 characters. |
option | RCPagingQueryOption | Query options including page token (optional, empty returns first page), count per page (max 100), and sort order (default descending). |
successBlock | Block | Success callback returning query results as RCPagingQueryResult array. |
errorBlock | Block | Failure callback. |
Type: RCPagingQueryOption
Parameter | Type | Description |
---|---|---|
pageToken | NSString | Pagination token. Pass nil or @"" for first page. If callback returns non-empty pageToken in result (RCPagingQueryResult), use it to fetch next page until empty. |
count | NSInteger | Items per page (max 200). |
order | BOOL | Sort by join time (default NO for descending, YES for ascending). |
Example code
- (void)searchJoinedGroups:(NSString *)pageToken {
// Group name to search
NSString *groupName = @"groupName";
// Query options
RCPagingQueryOption *option = [[RCPagingQueryOption alloc] init];
// Page token (nil for first page)
option.pageToken = pageToken;
// Items per page
option.count = 20;
// Sort order (default NO for descending)
option.order = NO;
[[RCCoreClient sharedCoreClient] searchJoinedGroups:groupName option:option
success:^(RCPagingQueryResult<RCGroupInfo *> * _Nonnull result) {
// Search succeeded
if (result.pageToken.length > 0) {
// Fetch next page
[self searchJoinedGroups:result.pageToken];
} else {
// Search completed
}
} error:^(RCErrorCode errorCode) {
// Search failed
}];
}