Skip to main content

Deleting channels

Remove one or more channels from the channel list using the SDK's delete feature. The channel list on the client is generated from local messages, so deleting a channel removes its local record only.

Delete a single channel

Call channel.delete() to remove a specific channel from the channel list. This method does not delete messages within the channel — it only removes the channel from the SDK's channel list. After successful deletion, refresh your UI to stop displaying the channel.

kotlin
val channel = DirectChannel("userId")

channel.delete { success, error ->
if (error == null && success == true) {
// Channel deleted successfully
} else {
// Deletion failed: ${error?.message}
}
}
tip

If a new message arrives in a deleted channel, the channel reappears in the channel list. The user can then view the channel's message history and the latest message.

The SDK does not provide a single API to delete both a channel and its message history. To also delete messages, call the message deletion API separately when deleting the channel. See Deleting Messages for details.

Delete multiple channels

Call BaseChannel.deleteChannels() to delete multiple channels at once. Supported channel types: direct, group, system, and community channels.

kotlin
val identifiers = listOf(
ChannelIdentifier(ChannelType.DIRECT, "userId1"),
ChannelIdentifier(ChannelType.GROUP, "groupId1")
)

BaseChannel.deleteChannels(identifiers) { success, error ->
if (error == null && success == true) {
// Deleted successfully
} else {
// Deletion failed: ${error?.message}
}
}

Parameters

ParameterTypeDescription
identifiersList<ChannelIdentifier>List of channel identifiers. Maximum 20 items. Each ChannelIdentifier requires a ChannelType and a channel ID.
handlerOperationHandler<Boolean>Callback for the operation result.
info

This API only deletes channel records from the current user's local database. If your app has enabled cloud message storage, the user's server-side message history is not affected. To also delete server-side message history, see Deleting Messages.

Delete all channels

The SDK does not provide a method to delete all channels at once. To achieve this, retrieve the channel list first and then delete each channel individually.