Delete messages

Delete() either permanently removes a historical message from Message Persistence (DeleteMessageHard()) or marks it as deleted if you use the soft delete option (DeleteMessage()).

icon

Usage in Blueprints and C++


Requires Message Persistence configuration

To manage messages, you must enable Message Persistence for your app's keyset in the Admin Portal. To delete messages from PubNub storage, you must also mark the Enable Delete-From-History option.

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.

Basic usage

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

#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 16 lines

Delete a message (hard delete)

Method signature

This method permanently removes a message from Message Persistence.

Output

TypeDescription
boolWhether or not the deletion was successful.

Basic usage

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

#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 16 lines
Last updated on