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 group 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")

Each call to initWithChannelId: returns a new channel instance configured with the given ID.

Get a channel instance

swift
import NexconnChatSDK
let identifier = ChannelIdentifier(channelType: .direct, channelId: "userId")
BaseChannel.getChannels(identifiers: [identifier]) { channels, error in
guard let channel = channels?.first else { return }
print("Channel loaded: \(channel.channelId)")
}

If you already know the channel type and ID, you can also create a typed instance with initWithChannelId: and then call reloadWithCompletion: to fetch the latest state.

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])
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.loadNextPage { page, error in
let channels = page?.data ?? []
// Handle results
}

Mark multiple channels as read

swift
import NexconnChatSDK
for channel in channels {
channel.clearUnreadCount(completion: nil)
}

Delete multiple channels

Use deleteChannels:completion: (see Delete a channel).

Clear unread count

Use clearUnreadCountWithCompletion: on a channel instance (see Handle unread count).