On this page

Message Persistence API for Unreal SDK

Message Persistence gives you real-time access to the history of messages published to PubNub. Each message is timestamped to the nearest 10 nanoseconds and stored across multiple availability zones in several geographic locations. You can encrypt stored messages with AES-256 so they are not readable on PubNub’s network. For details, see Message Persistence.

You control how long messages are stored through your account’s retention policy. Options include: 1 day, 7 days, 30 days, 3 months, 6 months, 1 year, or Unlimited.

You can retrieve the following:

  • Messages
  • Message reactions
  • Files (using the File Sharing API)
icon

Usage in Blueprints and C++

Fetch history

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal.

This function fetches historical messages from one or multiple channels. The IncludeMessageActions flag also allows you to fetch message actions along with the messages.

It's possible to control how messages are returned and in what order.

  • If you specify only the Start parameter (without End), you receive messages older than the Start timetoken.
  • If you specify only the End parameter (without Start), you receive messages from that End timetoken and newer.
  • If you specify both Start and End, you receive messages between those timetokens (inclusive of End).

Returns up to 100 messages on a single channel, or 25 per channel on up to 500 channels. To page, iteratively update the Start timetoken.

Method(s)

1PubnubSubsystem->FetchHistory(
2 FString Channel,
3 FOnFetchHistoryResponse OnFetchHistoryResponse,
4 FPubnubFetchHistorySettings FetchHistorySettings = FPubnubFetchHistorySettings()
5);
* required
ParameterDescription
Channel *
Type: FString
The channel to get the historical messages of.
OnFetchHistoryResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnFetchHistoryResponseNative to handle the result using a lambda.
FetchHistorySettingsStruct defining history configuration.

FPubnubFetchHistorySettings


* required
ParameterDescription
MaxPerChannel
Type: int
Specifies the number of historical messages to return. Default and maximum is 100 for a single channel, 25 for multiple channels, and 25 if IncludeMessageActions is true.
Reverse
Type: bool
Setting to true will traverse the time line in reverse starting with the oldest message first. Default is false.
Start
Type: FString
timetoken delimiting the start of time slice (exclusive) to pull messages from.
End
Type: FString
timetoken delimiting the end of time slice (inclusive) to pull messages from.
IncludeMeta
Type: bool
Whether meta (passed when Publishing the message) should be included in response or not.
IncludeMessageType
Type: bool
Pass true to receive the message type with each history message. Default is false.
IncludeUserID
Type: bool
Pass true to receive the publisher uuid with each history message. Default is false.
IncludeMessageActions
Type: bool
The flag denoting to retrieve history messages with message actions. If true, the method is limited to one channel and 25 messages only. Default is false.
IncludeCustomMessageType
Type: bool
Indicates whether to retrieve messages with the custom message type.

For more information, refer to Retrieving Messages.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


Sep 3, 2025