Delete channels
Delete a channel permanently with delete() or deleteChannel().
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()1channel.delete(): PNFuture<Unit> -
deleteChannel()1chat.deleteChannel(id: String): PNFuture<Unit>
Input
| Parameter | Required in delete() | Required in deleteChannel() | Description |
|---|---|---|---|
idType: StringDefault: n/a | No | Yes | Unique channel identifier. |
Output
| Method | Description |
|---|---|
delete()Type: PNFuture<Unit> | Returns when the channel is successfully deleted. |
deleteChannel()Type: PNFuture<Unit> | Returns when the channel is successfully deleted. |
Sample code
Delete the support channel.
-
delete()
show all 16 lines1// reference the "channel" object and invoke the "delete()" method
2chat.getChannel("support").async { result ->
3 result.onSuccess { channel ->
4 if (channel != null) {
5 channel.delete().async { deleteResult ->
6 deleteResult.onSuccess {
7 // handle success
8 }.onFailure {
9 // handle failure
10 }
11 }
12 }
13 }.onFailure {
14 // handle failure
15 } -
deleteChannel()1// reference the "chat" object and invoke the "deleteChannel()" method
2chat.deleteChannel("support").async { result ->
3 result.onSuccess {
4 // handle success
5 }.onFailure {
6 // handle failure
7 }
8}