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.

swift
import NexconnChatSDK

GroupChannel.getGroupsInfo(groupIds: ["groupId1", "groupId2"]) { groups, error in
if error == nil {
// Success
}
}

Get joined groups by ID

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

swift
import NexconnChatSDK

GroupChannel.getJoinedGroups(groupIds: ["groupId1", "groupId2"]) { groups, error in
if error == nil {
// Success
}
}

Get joined groups by role (paginated)

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

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
}
}

Role enum:

ValueDescription
NCGroupMemberRoleUndefAll roles
NCGroupMemberRoleNormalChannel member
NCGroupMemberRoleAdminChannel admin
NCGroupMemberRoleOwnerChannel owner

Search joined groups by name

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

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
}
}