Join an open channel
You can join an open channel in the following ways:
- Your app backend creates the open channel via the Server API Create Channel, then distributes the channel ID to the client. The client then joins using this ID.
- After a network disconnection, the SDK automatically rejoins the open channel — no app-side handling is needed.
Your backend can register the Channel Status Sync server callback to receive notifications for channel creation, participant join, and other events. The client can receive notifications by listening to channel events.
Limitations
- By default, a user can only be in one open channel at a time. Joining a new channel automatically leaves the previous one. Enable Allow user to join multiple open channels in the Console.
- On join, the client can fetch up to 50 recent messages. The SDK default is
20, and you can configure specific message types to fetch in the Console.
Join an existing open channel
Use OpenChannel("id").enterChannel() to join an existing open channel. The ErrorHandler callback returns null on success or an error on failure. You can also listen for OpenChannelHandler.onEntered to receive the join response object, or OpenChannelHandler.onEnterFailed for failure details.
Parameters (EnterOpenChannelParams)
| Parameter | Type | Description |
|---|---|---|
messageCount | Int | Number of recent messages to fetch on join (-1..50). Pass -1 to skip fetching messages. Pass 0 to use the SDK default. Default: -1. |
extra | String? | Additional information. Max 128 characters. |
- Kotlin
- Java
val openChannel = OpenChannel("openChannelId")
val params = EnterOpenChannelParams().apply {
messageCount = 50
}
openChannel.enterChannel(params) { error ->
if (error == null) {
// Joined successfully
} else {
// Join failed
}
}
OpenChannel openChannel = new OpenChannel("openChannelId");
EnterOpenChannelParams params = new EnterOpenChannelParams();
params.setMessageCount(50);
openChannel.enterChannel(params, error -> {
if (error == null) {
// Joined successfully
} else {
// Join failed
}
});
Auto-rejoin after reconnection
The SDK has a built-in reconnection mechanism. After reconnecting, it automatically rejoins any open channel the user was previously in. You do not need extra app-side handling. You can receive notifications by listening to channel status.
After a reconnect, the SDK automatically fetches messages based on the messageCount value passed when originally joining. Some fetched messages may already exist locally, so your app may need to deduplicate before displaying them.