Skip to main content

Deleting group channels

Remove one or more group 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 the local record only.

Delete a single group channel

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

kotlin
val channel = GroupChannel("groupId")

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 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. 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 channelIdentifiers = listOf(
ChannelIdentifier(ChannelType.GROUP, "groupId1"),
ChannelIdentifier(ChannelType.GROUP, "groupId2"),
ChannelIdentifier(ChannelType.DIRECT, "userId1")
)

BaseChannel.deleteChannels(channelIdentifiers) { 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, server-side message history is not affected. To also delete server-side 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.