Get channel details

Fetch details of a specific channel using the getChannel() method.

Requires App Context

To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.

Method signature

This method takes the following parameters:

chat.getChannel(
channelId: String
) async throws -> ChannelImpl?

Input

* required
ParameterDescription
channelId *
Type: String
Default:
n/a
Unique channel identifier (up to 92 UTF-8 byte sequences).

Output

ParameterDescription
ChannelImpl
Object returning the new channel metadata.

Basic usage

Sample code

The code samples in Swift Chat SDK focus on asynchronous code execution.

You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.

Fetch the support channel metadata.

// Assuming you have a reference of type "ChatImpl" named "chat"
Task {
if let channel = try await chat.getChannel(channelId: "support") {
debugPrint("Fetched channel metadata with ID: \(channel.id)")
} else {
debugPrint("Channel not found")
}
}
Last updated on