Leave channels

Requires App Context

To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.

Use the Leave() method to remove user's channel membership and unsubscribe them from receiving messages and events. Additionally, all the other listeners get the presence update that the user has left the channel and the membership is also removed from the channel.

Method signature

This method has the following signature:

channel.Leave()

Input

This method doesn't take any parameters.

Output

This method doesn't return any data.

Basic usage

Leave the support channel.

// reference the "channel" object
if (!chat.TryGetChannel("support", out var channel))
{
Console.WriteLine("Couldn't find channel!");
return;
};

channel.OnMessageReceived += OnMessageReceivedHandler; // or use lambda
void OnMessageReceivedHandler(Message message)
{
Console.WriteLine($"Message received: {message.Text}");
}
// join the channel and add metadata to the newly created membership
channel.Join()
// and leave
show all 16 lines
Last updated on