Manage channel updates
Update channel metadata and receive real-time change events.
Requires App Context
Enable App Context for your keyset in the Admin Portal.
Update channel details
Edit channel metadata with update() or updateChannel().
Both methods produce the same result. Call update() on a Channel object or updateChannel() on the Chat object with the channel ID.
Method signature
These methods take the following parameters:
-
update()(on theChannelobject)1channel.update(
2 name: String? = nil,
3 custom: [String: JSONCodableScalar]? = nil,
4 description: String? = nil,
5 status: String? = nil,
6 type: ChannelType? = nil
7) async throws -> ChannelImpl -
updateChannel()(on theChatobject)1chat.updateChannel(
2 name: String? = nil,
3 custom: [String: JSONCodableScalar]? = nil,
4 description: String? = nil,
5 status: String? = nil,
6 type: ChannelType? = nil
7) async throws -> ChannelImpl
Input
| Parameter | Required in update() | Required in updateChannel() | Description |
|---|---|---|---|
idType: StringDefault: n/a | No | Yes | Unique channel identifier. |
nameType: StringDefault: n/a | No | No | Display name for the channel. |
customType: [String: JSONCodableScalar]Default: n/a | No | No | JSON providing custom data about the channel. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn’t support filtering by custom properties. |
descriptionType: StringDefault: n/a | No | No | Additional details about the channel. |
statusType: StringDefault: n/a | No | No | Tag that categorizes a channel by its state, like archived. |
typeType: ChannelTypeDefault: n/a | No | No | Tag that categorizes a channel by its function, like offtopic. |
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Output
| Parameter | Description |
|---|---|
ChannelImpl | Object containing the updated channel with its metadata. |
Sample code
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.
Update the description of the support channel.
update()
1
Get channel updates
Receive real-time updates when a Channel object is edited with onUpdated(), or be notified when it is deleted with onDeleted().
You can also use channel.stream.updates() and channel.stream.deletions() for AsyncStream-based equivalents.
For monitoring multiple channels at once, streamUpdatesOn() remains available.
Deprecation
streamUpdates() is deprecated. Use onUpdated() and onDeleted() (closure-based) or channel.stream.updates() and channel.stream.deletions() (AsyncStream-based) instead.
Method signature
-
onUpdated()— closure called when the channel metadata changes1channel.onUpdated(
2 callback: @escaping (ChannelImpl) -> Void
3) -> AutoCloseable -
onDeleted()— closure called when the channel is deleted1channel.onDeleted(
2 callback: @escaping () -> Void
3) -> AutoCloseable -
streamUpdatesOn()(static) — monitors multiple channels1ChannelImpl.streamUpdatesOn(
2 channels: [ChannelImpl]
3) -> AsyncStream<[ChannelImpl]>
Input
| Parameter | Description |
|---|---|
callback (in onUpdated) *Type: (ChannelImpl) -> VoidDefault: n/a | Closure called with the updated channel whenever its metadata changes. |
callback (in onDeleted) *Type: () -> VoidDefault: n/a | Closure called when the channel is deleted. |
channels (in streamUpdatesOn) *Type: [ChannelImpl]Default: n/a | A collection of ChannelImpl objects for which you want to get updates. |
Output
| Parameter | Description |
|---|---|
AutoCloseable | An object you must retain. When released or closed, the listener stops. |
Sample code
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.
Get updates on the support channel.
- Closure
- AsyncStream
1
1
Watch multiple channels
Get updates on multiple channel objects at once.
- Closure
- AsyncStream
1
1