Skip to main content

Search group channels

This guide covers retrieving group info, listing joined groups, and searching groups.

Get group info

Call getGroupsInfoWithGroupIds:completion: to retrieve group profiles. The method checks the local cache first, then fetches from the server if the cache is older than 10 minutes or the user is not in the group. Max 20 groups per call, max 5 calls per second.

objc
[NCGroupChannel getGroupsInfoWithGroupIds:@[@"groupId1", @"groupId2"]
completion:^(NSArray<NCGroupInfo *> *groups, NCError *error) {
if (error == nil) {
// Success
}
}];

Get joined groups by ID

Call getJoinedGroupsWithGroupIds:completion: to get info for specific joined groups (max 20 per call):

objc
[NCGroupChannel getJoinedGroupsWithGroupIds:@[@"groupId1", @"groupId2"]
completion:^(NSArray<NCGroupInfo *> *groups, NCError *error) {
if (error == nil) {
// Success
}
}];

Get joined groups by role (paginated)

Call createJoinedGroupsByRoleQueryWithParams: on NCGroupChannel to create a paged query object, then call loadNextPageWithCompletion::

objc
NCJoinedGroupsByRoleQueryParams *params = [[NCJoinedGroupsByRoleQueryParams alloc] init];
params.role = NCGroupMemberRoleUndef;
params.pageSize = 20;
params.isAscending = NO;

NCJoinedGroupsByRoleQuery *query = [NCGroupChannel createJoinedGroupsByRoleQueryWithParams:params];
[query loadNextPageWithCompletion:^(NCJoinedGroupsByRolePageResult *result, NCError *error) {
if (error == nil && result.data.count > 0) {
// Load next page by calling loadNextPageWithCompletion: again
}
}];

Role enum:

ValueDescription
NCGroupMemberRoleUndefAll roles
NCGroupMemberRoleNormalChannel member
NCGroupMemberRoleManagerChannel admin
NCGroupMemberRoleOwnerChannel owner

Search joined groups by name

Call createSearchJoinedGroupsQueryWithParams: on NCGroupChannel to create a paged search query:

objc
NCSearchJoinedGroupsQueryParams *params = [[NCSearchJoinedGroupsQueryParams alloc] init];
params.groupName = @"searchQuery";
params.pageSize = 20;

NCSearchJoinedGroupsQuery *query = [NCGroupChannel createSearchJoinedGroupsQueryWithParams:params];
[query loadNextPageWithCompletion:^(NSArray<NCGroupInfo *> *groups, NCError *error) {
if (error == nil && groups.count > 0) {
// Load next page by calling loadNextPageWithCompletion: again
}
}];