Get channel details
Fetch details of a specific channel using the TryGetChannel()
or GetChannelAsync
methods.
Requires App Context
To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
These methods take the following parameters:
- Sync
- Async
chat.TryGetChannel(
string channelId,
out Channel channel
)
Input
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | string | Yes | n/a | Unique channel identifier (up to 92 UTF-8 byte sequences). |
channel | out Channel | Yes | n/a | The channel to populate with the appropriate Channel object if the method returns true. If it returns false, the channel remains uninitialized. |
Output
If the method returns true
, the out channel
parameter is populated with the appropriate Channel
object. If it returns false, the channel
remains uninitialized.
Basic usage
Fetch the support
channel metadata.
if (chat.TryGetChannel("support", out var channel))
{
Console.WriteLine($"Found channel with name {channel.Name}");
};
chat.GetChannelAsync(
string channelId
)
Input
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
channelId | string | Yes | n/a | Unique channel identifier (up to 92 UTF-8 byte sequences). |
Output
The method returns an awaitable Task<Channel?>
or null
if the channel ID wasn't found.
Basic usage
Asynchronously fetch the support
channel metadata.
var channel = await chat.GetChannelAsync("support");
if (channel != null)
{
Console.WriteLine($"Found channel with name {channel.Name}");
};