Delete messages
delete() permanently removes a message from Message Persistence or marks it as deleted (soft delete).
Requires Message Persistence
Enable Message Persistence and Enable Delete-From-History in the Admin Portal.
Method signature
This method takes the following parameters:
1message.delete(
2 soft: Bool = false,
3 preserveFiles: Bool = false
4) async throws -> MessageImpl?
Input
* required
| Parameter | Description |
|---|---|
softType: BoolDefault: false | Define if you want to permanently remove message data. By default, the message data gets permanently deleted from Message Persistence. If you set this parameter to true, the Message object gets the deleted status and you can still restore/get its data. |
preserveFilesType: BoolDefault: false | Define if you want to keep the files attached to the message or remove them. |
Output
| Parameter | Description |
|---|---|
MessageImpl | For hard delete, the method returns nil. For soft delete, an updated message instance with an added deleted action type. |
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 message with the 16200000000000001 timetoken from the support channel.
1
Other examples
Archive (soft delete) the message with the 16200000000000001 timetoken from the support channel, keeping its data in Message Persistence.
1