Skip to main content

Join an open channel

To join an open channel, create an NCOpenChannel instance with the channel ID, then call enterChannel(params:completion:).

  • The SDK automatically rejoins open channels after a network reconnection if the user has not explicitly exited.
  • Create the open channel via the Server API, then distribute the channel ID to clients to join.

Limitations

  • By default, a user can only be in one open channel at a time. Joining a new channel automatically exits the previous one. Enable Allow single user to join multiple open channels in the Console to change this behavior.
  • On join, the SDK retrieves up to 50 recent messages. The iOS SDK default is 20. Configure Join open channel message type filtering in the Console to limit which message types are retrieved.

Join an existing open channel

swift
import NexconnChatSDK

guard let channel = OpenChannel(channelId: "channelId") else {
return
}

let params = EnterOpenChannelParams()
params.messageCount = 20
params.extra = nil

channel.enterChannel(params: params) { response, error in
if let error {
print("Failed to join: \(error.localizedDescription)")
return
}

guard let response else { return }
print("Joined. Members: \(response.memberCount)")
print("Channel created at: \(response.createTime)")
print("All muted: \(response.isAllChannelMuted)")
print("Current user muted: \(response.isCurrentUserMuted)")
}

NCEnterOpenChannelParams

ParameterTypeDefaultDescription
messageCountNSInteger20Number of recent messages to retrieve on enter. Value rules: -1 = retrieve no history, 0 = use SDK default (20), 1...50 = retrieve that number of recent messages.
extraNSStringnilOptional extra information.

NCOpenChannelEnterResponseInfo

PropertyTypeDescription
createTimeint64Channel creation time (millisecond timestamp)
memberCountNSIntegerCurrent member count
isAllChannelMutedBOOLWhether the channel is globally muted
isCurrentUserMutedBOOLWhether the current user is globally muted
isCurrentChannelMutedBOOLWhether the current user is muted in this channel
isCurrentChannelInAllowlistBOOLWhether the current user is on the channel's mute allowlist
enterTimeint64Channel join time (millisecond timestamp)

Auto-rejoin after reconnection

The SDK automatically rejoins open channels after a network reconnection. No action is required. After rejoining, the SDK retrieves the same number of messages as in the original join call.

tip

Messages retrieved after reconnection may already exist locally. Deduplicate before displaying.