On this page

Get message details

Get message details, retrieve content, and check if the message was deleted.

icon

Usage in Blueprints and C++


Asynchronous and synchronous method execution

Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.

  • Asynchronous methods (Async suffix) return void and 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 Native suffix (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.

Output

FieldTypeDescription
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.

Actor.h
1

Actor.cpp
1

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

Output

TypeDescription
FString
Current text content of the message, reflecting any edits.

Sample code

Get the content of the message with the 16200000000000000 timetoken.

1

Get message timetoken

GetMessageTimetoken() returns the unique timetoken identifier of the message.

Method signature

Output

TypeDescription
FString
Timetoken of the message.

Sample code

Get the timetoken of a message.

1

Get message type

GetType() returns the type of the message as a string.

Method signature

Output

TypeDescription
FString
Type of the message (for example, "text").

Sample code

Get the type of a message.

1

Get message data

GetMessageData() returns the full message data struct.

Method signature

Output

TypeDescription
FPubnubChatMessageData
Struct containing the full message data (Type, Text, ChannelID, UserID, Meta, MessageActions).

Sample code

Get the full data of a message.

1

Check deletion status

IsDeleted() checks whether the message has been soft-deleted.

Method signature

Output

FieldTypeDescription
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.

1