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)
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
Startparameter (withoutEnd), you receive messages older than theStarttimetoken. - If you specify only the
Endparameter (withoutStart), you receive messages from thatEndtimetoken and newer. - If you specify both
StartandEnd, you receive messages between those timetokens (inclusive ofEnd).
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);
| Parameter | Description |
|---|---|
Channel *Type: FString | The channel to get the historical messages of. |
OnFetchHistoryResponse *Type: FOnFetchHistoryResponse | 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. |
FetchHistorySettings | Struct defining history configuration. |
FPubnubFetchHistorySettings
| Parameter | Description |
|---|---|
MaxPerChannelType: 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. |
ReverseType: bool | Setting to true will traverse the time line in reverse starting with the oldest message first. Default is false. |
StartType: FString | timetoken delimiting the start of time slice (exclusive) to pull messages from. |
EndType: FString | timetoken delimiting the end of time slice (inclusive) to pull messages from. |
IncludeMetaType: bool | Whether meta (passed when Publishing the message) should be included in response or not. |
IncludeMessageTypeType: bool | Pass true to receive the message type with each history message. Default is false. |
IncludeUserIDType: bool | Pass true to receive the publisher uuid with each history message. Default is false. |
IncludeMessageActionsType: 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. |
IncludeCustomMessageTypeType: bool | Indicates whether to retrieve messages with the custom message type. For more information, refer to Retrieving Messages. |
Sample code
Reference code
ACTION REQUIRED before running the code.