On this page

Delete channels

Unity Chat SDK lets you remove an existing channel. You can remove the channel either with or without deleting its historical data from App Context storage using one of these methods: Delete() and DeleteChannel().

Both of these methods give the same output. The only difference is that you call a given method either on the Chat (DeleteChannel()) or the Channel (Delete()) object. Depending on the object, these methods take a different set of input parameters - you either have to specify the channel ID you want to delete or not because it's already known.

Requires App Context

To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.

Method signature

These methods take the following parameters:

  • Delete() (on the Channel object)

    1channel.Delete(bool soft = false)
  • DeleteChannel() (on the Chat object)

    1chat.DeleteChannel(
    2 string channelId,
    3 bool soft = false
    4 )

Input

ParameterRequired in Delete()Required in DeleteChannel()Description
channelId
Type: string
Default:
n/a
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's IsDeleted property is set to true, and you can still restore/get its data.

Output

TypeDescription
Task<ChatOperationResult>
Returned Task that you can await to get the result of the delete operation.

Sample code

Permanently delete the channel with the ID of support.

  • Delete() (on the Channel object)

    1
    
  • DeleteChannel() (on the Chat object)

    1
    

Other examples

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

1

Last updated on