Skip to main content

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.

tip

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

ParameterTypeDescription
groupIdsNSArrayList of targetIds for groups to query (max 20 per call)
successBlockBlockSuccess callback returning an array of RCGroupInfo objects
errorBlockBlockFailure 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

ParameterTypeDescription
groupIdsNSArrayList of targetIds for joined groups (max 20 per call)
successBlockBlockSuccess callback returning an array of RCGroupInfo objects
errorBlockBlockFailure 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

ParameterTypeDescription
roleRCGroupMemberRoleGroup member role
optionRCPagingQueryOptionPagination options including page token (optional), page size (max 100), and sort order (default descending)
successBlockBlockSuccess callback returning RCPagingQueryResult with group data
errorBlockBlockFailure callback

Type: RCGroupMemberRole

Enum ValueRole Description
RCGroupMemberRoleUndefUndefined role (queries all member types)
RCGroupMemberRoleNormalRegular group member
RCGroupMemberRoleManagerAdministrator
RCGroupMemberRoleOwnerGroup Owner

Type: RCPagingQueryOption

ParameterTypeDescription
pageTokenNSStringPagination token. Pass nil or @"" for first page. Subsequent calls should use the token returned in result.pageToken until empty string indicates completion.
countNSIntegerPage size (max 200)
orderBOOLSort 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

ParameterTypeDescription
groupNameNSStringGroup name (required), maximum 64 characters.
optionRCPagingQueryOptionQuery options including page token (optional, empty returns first page), count per page (max 100), and sort order (default descending).
successBlockBlockSuccess callback returning query results as RCPagingQueryResult array.
errorBlockBlockFailure callback.

Type: RCPagingQueryOption

ParameterTypeDescription
pageTokenNSStringPagination token. Pass nil or @"" for first page. If callback returns non-empty pageToken in result (RCPagingQueryResult), use it to fetch next page until empty.
countNSIntegerItems per page (max 200).
orderBOOLSort 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
}];
}