Get message details
Get message details, retrieve content, and check if the message was deleted.
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.1Channel->GetMessageAsync(Timetoken, OnGetMessageResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatMessageResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatMessageResult Result = Channel->GetMessage(Timetoken);
Get message details
GetMessage() fetches the Message object from Message Persistence based on the message timetoken.
- Blueprint
- C++ / Input parameters
1Channel->GetMessage(FString Timetoken);
| Parameter | Description |
|---|---|
TimetokenType: FStringDefault: n/a | Timetoken of the message you want to retrieve from Message Persistence. |
Output
| Field | Type | Description |
|---|---|---|
Result | FPubnubChatOperationResult | Operation result with Error (bool) and ErrorMessage (FString). |
Message | UPubnubChatMessage* | Returned Message object. |
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.
Fetch a specific message by timetoken asynchronously.
Get historical details
If you have Message Persistence enabled on your keyset, PubNub stores all historical info about messages, their metadata, and reactions.
If you want to fetch historical details of a given message, use the GetHistory() method. By default, when you fetch historical messages, PubNub returns all message actions and metadata attached to the retrieved messages.
Get message content
GetCurrentText() returns the current text content of a message. If the message has been edited, this method computes the latest text from message actions.
Method signature
- Blueprint
- C++ / Input parameters
1Message->GetCurrentText();
Output
| Type | Description |
|---|---|
FString | Current text content of the message, reflecting any edits. |
Sample code
Get the content of the message with the 16200000000000000 timetoken.
- C++
- Blueprint
1
Get message timetoken
GetMessageTimetoken() returns the unique timetoken identifier of the message.
Method signature
- Blueprint
- C++ / Input parameters
1Message->GetMessageTimetoken();
Output
| Type | Description |
|---|---|
FString | Timetoken of the message. |
Sample code
Get the timetoken of a message.
- C++
- Blueprint
1
Get message type
GetType() returns the type of the message as a string.
Method signature
- Blueprint
- C++ / Input parameters
1Message->GetType();
Output
| Type | Description |
|---|---|
FString | Type of the message (for example, "text"). |
Sample code
Get the type of a message.
- C++
- Blueprint
1
Get message data
GetMessageData() returns the full message data struct.
Method signature
- Blueprint
- C++ / Input parameters
1Message->GetMessageData();
Output
| Type | Description |
|---|---|
FPubnubChatMessageData | Struct containing the full message data (Type, Text, ChannelID, UserID, Meta, MessageActions). |
Sample code
Get the full data of a message.
- C++
- Blueprint
1
Check deletion status
IsDeleted() checks whether the message has been soft-deleted.
Method signature
- Blueprint
- C++ / Input parameters
1Message->IsDeleted();
Output
| Field | Type | Description |
|---|---|---|
Result | FPubnubChatOperationResult | Operation result with Error (bool) and ErrorMessage (FString). |
IsDeleted | bool | Info on whether the message has the deleted status (because it was previously soft-deleted) or not. |
Sample code
Check the deletion status of a message.
- C++
- Blueprint
1