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.
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.
- Blueprint
- C++ / Input parameters
1// soft delete
2Message->DeleteMessage();
Output
| Type | Description |
|---|---|
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 linesDelete a message (hard delete)
Method signature
This method permanently removes a message from Message Persistence.
- Blueprint
- C++ / Input parameters
1// hard delete
2Message->DeleteMessageHard();
Output
| Type | Description |
|---|---|
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