On this page

Delete channels

Remove a channel permanently or soft-delete it (keeping historical data in App Context storage) with delete() or deleteChannel().

Both methods produce the same result. Call delete() on a Channel object or deleteChannel() on the Chat object with the channel ID.

Requires App Context

Enable App Context for your keyset in the Admin Portal.

Method signature

These methods take the following parameters:

  • delete() (on the Channel object)

    1channel.delete(
    2 soft: Bool = false
    3) async throws -> ChannelImpl?
  • deleteChannel() (on the Chat object)

    1chat.deleteChannel(
    2 id: String,
    3 soft: Bool = false
    4) async throws -> ChannelImpl?

Input

ParameterRequired in delete()Required in deleteChannel()Description
id
Type: String
Default:
false
No
Yes
Unique channel identifier.
soft
Type: Bool
Default:
false
No
No
Define if you want to permanently remove channel metadata. The channel metadata gets permanently deleted from the App Context storage by default. If you set this parameter to true, the Channel object gets the deleted status, and you can still restore/get its data.

Output

ParameterDescription
ChannelImpl?
For hard delete, the method returns nil. For soft delete, it returns an updated channel instance with the status field set to deleted.

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.

Permanently delete the support channel metadata.

  • delete()
1

Other examples

Archive (soft delete) the channel with the ID of support, keeping its data in the App Context storage.

  • delete(soft: true)
1

Last updated on