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 the Channel object)

    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 the Chat object)

    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​

ParameterRequired in update()Required in updateChannel()Description
id
Type: String
Default:
n/a
NoYesUnique channel identifier.
name
Type: String
Default:
n/a
NoNoDisplay name for the channel.
custom
Type: [String: JSONCodableScalar]
Default:
n/a
NoNoJSON 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.
description
Type: String
Default:
n/a
NoNoAdditional details about the channel.
status
Type: String
Default:
n/a
NoNoTag that categorizes a channel by its state, like archived.
type
Type: ChannelType
Default:
n/a
NoNoTag 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​

ParameterDescription
ChannelImplObject 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 changes

    1channel.onUpdated(
    2 callback: @escaping (ChannelImpl) -> Void
    3) -> AutoCloseable
  • onDeleted() — closure called when the channel is deleted

    1channel.onDeleted(
    2 callback: @escaping () -> Void
    3) -> AutoCloseable
  • streamUpdatesOn() (static) — monitors multiple channels

    1ChannelImpl.streamUpdatesOn(
    2 channels: [ChannelImpl]
    3) -> AsyncStream<[ChannelImpl]>

Input​

* required
ParameterDescription
callback (in onUpdated) *
Type: (ChannelImpl) -> Void
Default:
n/a
Closure called with the updated channel whenever its metadata changes.
callback (in onDeleted) *
Type: () -> Void
Default:
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​

ParameterDescription
AutoCloseableAn 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.

1

Watch multiple channels​

Get updates on multiple channel objects at once.

1

Was this page useful?

Last updated on