Skip to main content

Channel overview

The Chat SDK uses channel objects to represent channels. All channel types (Direct, Group, Open, Community, System) inherit from NCBaseChannel.

Channel types

Nexconn supports multiple channel types for different use cases. The client SDK uses the NCChannelType enum:

Enum valueChannel type
NCChannelTypeDirectDirect channel
NCChannelTypeGroupGroup channel
NCChannelTypeCommunityCommunity channel
NCChannelTypeOpenOpen channel
NCChannelTypeSystemSystem channel

Direct channel

A one-to-one channel between two users. The two users do not need to be friends — Nexconn does not manage user relationships. Messages are stored in the local database.

Group channel

A channel with two or more users. Channel member information is managed by your app. Nexconn delivers messages to all channel members. Each group supports up to 3,000 members with no limit on the number of groups per app. Messages are stored in the local database.

Community channel

A multi-user chat with no member limit. Supports high-volume concurrent messaging and push notifications. Member information is managed by your app. Each user can join up to 100 community channels. Messages are stored in the local database. See Community channel overview.

Open channel

Supports unlimited participants with high-volume concurrent real-time messaging. Users stop receiving messages after leaving the open channel. No push notification support. The SDK does not save open channel messages — all data is cleared when the user leaves. See Open channel overview.

System channel

A channel where system accounts send messages to users. These channels can be created by broadcast messages or single notification messages (for example, friend request notifications).

Channel properties

The NCBaseChannel class provides the following key properties:

PropertyTypeDescription
channelTypeNCChannelTypeChannel type: direct, group, open, system, or community
channelIdNSStringChannel ID. For direct channels, this is the other user's ID. For group/open/community channels, this is the corresponding channel ID.
unreadCountNSIntegerNumber of unread messages
mentionedMeCountNSIntegerNumber of unread messages that mention the current user
mentionedCountNSIntegerTotal number of mention messages
isPinnedBOOLWhether the channel is pinned
noDisturbLevelNCChannelNoDisturbLevelDo not disturb level. See Do not disturb overview.
operationTimelong longOperation timestamp in milliseconds. Updated by pinning and other operations. Used as cursor for paginated queries.
latestMessageNCMessageLast message stored locally. See Message types.
draftNSStringDraft text saved in the channel. See Draft.
translateStrategyNCTranslateStrategyText translation strategy for this channel

latestMessage (NCMessage) key properties:

PropertyTypeDescription
clientIdlong longLocally unique message ID
messageIdNSStringServer-assigned globally unique message ID (only available for successfully sent messages)
senderUserIdNSStringSender's user ID
directionNCMessageDirectionMessage direction: send or receive
sentStatusNCSentStatusMessage sending status
sentTimelong longSend time (Unix timestamp in milliseconds)
messageTypeNSStringMessage type name
contentNCMessageContentMessage content body
metadataNSDictionaryMessage metadata
receivedStatusInfoNCMessageReceivedStatusInfoMessage received status

Basic channel operations

Create or get a channel instance

swift
import NexconnChatSDK
// Direct channel
let directChannel = DirectChannel(channelId: "userId")
// Group channel
let groupChannel = GroupChannel(channelId: "groupId")
// Open channel
let openChannel = OpenChannel(channelId: "chatroomId")

Returns nil if channelId is empty.

Release a channel instance

The current iOS SDK does not expose a destroy API on NCBaseChannel. Channel instances are lightweight objects. Release your own references when you no longer need an instance.

Create a channel list query

swift
import NexconnChatSDK
let params = ChannelsQueryParams()
params.setChannelTypes([.direct, .group])
params.pageSize = 20
let query = BaseChannel.createChannelsQuery(params: params)
query.loadNextPage { page, error in
let channels = page?.data ?? []
print("Loaded \(channels.count) channels")
}

Create a channel search query

swift
import NexconnChatSDK
let query = ChannelSearchQuery()
query.keyword = "Project"
query.limit = 20
query.loadNextPage { page, error in
let channels = page?.data ?? []
// Handle results
}

Delete channels

swift
import NexconnChatSDK
let id1 = ChannelIdentifier(channelType: .direct, channelId: "userId")
let id2 = ChannelIdentifier(channelType: .group, channelId: "groupId")
BaseChannel.deleteChannels(identifiers: [id1, id2]) { error in
if error == nil {
print("Channels deleted")
}
}

Clear unread count

swift
import NexconnChatSDK
guard let channel = DirectChannel(channelId: "targetUserId") else { return }
channel.clearUnreadCount { isCleared, error in
if isCleared {
print("Unread count cleared")
}
}