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. 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
- Blueprint
- C++ / Input parameters
Message->Restore();
Output
Type | Description |
---|---|
UPubnubMessage* | Object returning the restored Message object. |
Basic usage
Restore a previously soft deleted message with the 16200000000000001
timetoken.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("support");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
show all 18 lines