PubNub Message Persistence feature includes deleteMessages() API allowing to remove messages from storage. This, however, permanently deletes messages without the possibility of retrieving them later, if needed.
To remove messages from your chat application's UI and keep them in storage at the same time, you need to soft delete them and that is where Message Actions come to play.
By using addMessageAction() you can add deleted flag to a message.
pubnub.addMessageAction(
{
channel: 'ch-1'
messageTimetoken: '15610547826970040',
action: {
type: 'deleted',
value: '.',
},
},
function(status, response) {
}
);
Calling the method triggers an event allowing subscribed users to mark a message as deleted.
See also:
Javascript SDK Message Actions API
How do I clear channel history
In case of any questions, contact us at support@pubnub.com.