Delete messages
Delete() either marks a message as deleted (soft delete) or permanently removes it from Message Persistence (hard delete), depending on the Soft parameter.
Requires Message Persistence
Enable Message Persistence and Enable Delete-From-History in the Admin Portal.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Message->DeleteAsync(OnDeleteResponseDelegate, Soft);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Message->Delete(Soft);
Delete a message
Method signature
- Blueprint
- C++ / Input parameters
1Message->Delete(bool Soft = false);
| Parameter | Description |
|---|---|
SoftType: boolDefault: false | When true, the message is soft-deleted (marked with a deleted action type so you can still restore/get its data). When false, the message is permanently removed from Message Persistence. Hard delete also removes any thread associated with the message. |
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Delete a message asynchronously.