On this page

Delete messages

DeleteMessage() marks a message as deleted (soft delete) or DeleteMessageHard() permanently removes it from Message Persistence.

Requires Message Persistence

Enable Message Persistence and Enable Delete-From-History in the Admin Portal.

icon

Usage in Blueprints and C++


Mark message as deleted (soft delete)

Method signature

This method applies to the Message object the deleted status so you can still restore/get its data.

Output

TypeDescription
UPubnubMessage*
An updated message instance with an added deleted action type.

Sample code

Soft delete the message with the 16200000000000001 timetoken from the support channel.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15
show all 16 lines

Delete a message (hard delete)

Method signature

This method permanently removes a message from Message Persistence.

Output

TypeDescription
bool
Whether or not the deletion was successful.

Sample code

Permanently delete the message with the 16200000000000001 timetoken from the support channel.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15
show all 16 lines
Last updated on