Message Persistence provides real-time access to the history of all messages published to PubNub. Each published message is timestamped to the nearest 10 nanoseconds and is stored across multiple availability zones in several geographical locations. Stored messages can be encrypted with AES-256 message encryption, ensuring that they are not readable while stored on PubNub's network. For more information, refer to Message Persistence.
Messages can be stored for a configurable duration or forever, as controlled by the retention policy that is configured on your account. The following options are available: 1 day, 7 days, 30 days, 3 months, 6 months, 1 year, or Unlimited.
You can retrieve the following:
- Message actions
- File Sharing (using File Sharing API)
Requires Message Persistence
This function fetches historical messages of a channel.
It is possible to control how messages are returned and in what order, for example you can:
- Search for messages starting on the newest end of the timeline (default behavior -
- Search for messages from the oldest end of the timeline by setting
- Page through results by providing a
- Retrieve a slice of the time line by providing both a
- Limit the number of messages to a specific quantity using the
Start & End parameter usage clarity
If only the
start parameter is specified (without
end), you will receive messages that are older than and up to that
start timetoken value. If only the
end parameter is specified (without
start) you will receive messages that match that
end timetoken value and newer. Specifying values for both
end parameters will return messages between those timetoken values (inclusive on the
end value). Keep in mind that you will still receive a maximum of 100 messages even if there are more messages that meet the timetoken values. Iterative calls to history adjusting the
start timetoken is necessary to page through the full set of results if more than 100 messages meet the timetoken values.
History you can use the following method(s) in the Lua SDK:
history parameters. See History Parameters for more details.
|The channel to get history for.
|The function to call with received history.
|The function to call on failure, with result.
|integer or string
|The timetoken to start history from.
|integer or string
|The timetoken to stop history at.
|Whether to get the history in reverse (from chronological) order.
|Maximum number of messages to get in history (cannot be more than 100).
Messages are always returned sorted in ascending time direction from history regardless of
reverse direction matters when you have more than 100 (or
count, if it's set) messages in the time interval, in which case
reverse determines the end of the time interval from which it should start retrieving the messages.
Retrieve the last 100 messages on a channel:
channel = "demo",
count = 100,
callback = function(response)
error = function (response)