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.
- Swift
- Objective-C
swift
import NexconnChatSDK
GroupChannel.getGroupsInfo(groupIds: ["groupId1", "groupId2"]) { groups, error in
if error == nil {
// Success
}
}
Objective C
[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):
- Swift
- Objective-C
swift
import NexconnChatSDK
GroupChannel.getJoinedGroups(groupIds: ["groupId1", "groupId2"]) { groups, error in
if error == nil {
// Success
}
}
Objective C
[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::
- Swift
- Objective-C
swift
import NexconnChatSDK
let params = JoinedGroupsByRoleQueryParams()
params.role = .undef
params.pageSize = 20
params.isAscending = false
let query = GroupChannel.createJoinedGroupsByRoleQuery(params: params)
query.loadNextPage { page, error in
if error == nil, let groups = page?.data, !groups.isEmpty {
// Load next page by calling loadNextPage again
}
}
Objective C
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:
| Value | Description |
|---|---|
| NCGroupMemberRoleUndef | All roles |
| NCGroupMemberRoleNormal | Channel member |
| NCGroupMemberRoleAdmin | Channel admin |
| NCGroupMemberRoleOwner | Channel owner |
Search joined groups by name
Call createSearchJoinedGroupsQueryWithParams: on NCGroupChannel to create a paged search query:
- Swift
- Objective-C
swift
import NexconnChatSDK
let params = SearchJoinedGroupsQueryParams()
params.groupName = "searchQuery"
params.pageSize = 20
let query = GroupChannel.createSearchJoinedGroupsQuery(params: params)
query.loadNextPage { page, error in
if error == nil, let groups = page?.data, !groups.isEmpty {
// Load next page by calling loadNextPage again
}
}
Objective C
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
}
}];