/ SDKs / Flutter
SDKs
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Flutter
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Enter and exit an open channel

Copy link

A user can enter up to ten open channels and only receives messages from the entered channels. If the user is disconnected from the Sendbird server with the disconnect() method, they can no longer receive messages. To continue receiving messages from open channels they are participating in, the user has to be reconnected to the server with the connect() method and re-enter the open channels.

If the client app is in the background, the user is disconnected from the Sendbird server. However, when the client app runs in the foreground again, the Chat SDK automatically reconnects the open channels the user has entered.

When a user temporarily loses connection to the Sendbird server due to an unstable connection, the SendbirdSdk instance attempts to reconnect the user and the open channels they have entered.

try {
    final channel = await OpenChannel.getChannel(CHANNEL_URL);
    await channel.enter();
    // The current user successfully enters the open channel.
} catch (e) {
    // Handle error.
}

A user can exit open channels as shown below. After exiting, the user can no longer receive messages from the channel.

try {
    final channel = await OpenChannel.getChannel(CHANNEL_URL);
    await channel.exit();
    // The current user successfully exits the open channel.
} catch (e) {
    // Handle error.
}