/ SDKs / Unreal
SDKs
Chat SDKs Unreal v3
Chat SDKs Unreal
Chat SDKs
Unreal
Version 3

Delete a message

Copy link

A user can delete any messages sent by themselves. An error is returned if a user attempts to delete the messages of other participants. Also, channel operators can delete any messages in the channel.

// The BASE_MESSAGE below indicates a BaseMessage object to delete.
channel->DeleteMessage(BASE_MESSAGE, [](SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // The message is successfully deleted from the channel.
})

If a message is deleted, the MessageDeleted() method in the channel event handler will be invoked on all channel participants' devices including the one that deleted the message.

class MyChannelHandler : public SBDChannelHandler {
    void MessageDeleted(SBDBaseChannel* channel, uint64_t message_id) {
        // Invoked when a message is removed from the channel.
    }
});

SBDMain::AddChannelHandler(UNIQUE_HANDLER_ID, new MyChannelHandler());