Restore messages

If you delete a message, you can restore its content together with the attached files using the restore() method.

This is possible, however, only if the message you want to restore was soft deleted (the soft parameter was set to true when deleting it). Hard deleted messages cannot be restored as their data is no longer available in Message Persistence.

Requires Message Persistence configuration

To manage messages, you must enable Message Persistence for your app's keyset in the Admin Portal and mark the Enable Delete-From-History option.

Method signature

This method has the following signature:

message.restore(
completion: ((Swift.Result<MessageImpl, Error>) -> Void)? = nil
)

Input

This method doesn't take any parameters.

Output

TypeDescription
((Swift.Result<MessageImpl, Error>) -> Void)Object returning the restored MessageImpl object.

Basic usage

Restore a previously soft deleted message with the 16200000000000001 timetoken.

/// Assuming you have a "chat" instance and "support" channel available

let timetoken: Timetoken = 16200000000000001

/// Fetch the channel metadata
chat?.getChannel(channelId: "support") { [weak self] in
switch $0 {
case let .success(channel):
if let channel = channel {
self?.channel = channel
/// Fetch the message with the specific timetoken on the "support" channel
channel.getMessage(timetoken: timetoken) {
switch $0 {
case let .success(message):
if let message = message {
show all 42 lines
Last updated on