fetchMessages
Fetch historical messages from 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. For example, you can:
Search for messages starting on the newest end of the timeline.
Search for messages from the oldest end of the timeline.
Page through results by providing a
startORendtime token.Retrieve a slice of the time line by providing both a
startANDendtime token.Limit the number of messages to a specific quantity using the
limitparameter.Batch history returns up to 25 messages per channel, on a maximum of 500 channels. Use the start and end timestamps to page through the next batch of messages.
Start & End parameter usage clarity:
If you specify only the
startparameter (withoutend), you will receive messages that are older than and up to thatstarttimetoken.If you specify only the
endparameter (withoutstart), you will receive messages from thatendtimetoken and newer.Specify values for both
startandendparameters to retrieve messages between those timetokens (inclusive of theendvalue).Keep in mind that you will still receive a maximum of 25 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 25 messages meet the timetoken values.
Parameters
Channels to return history messages from.
The paging object used for pagination. @see PNBoundedPage
Whether to include publisher uuid with each history message. Defaults to true.
Whether to include message metadata in response. Defaults to false.
Whether to include message actions in response. Defaults to false.
Whether to include message type in response. Defaults to false.
Whether to include custom message type in response. Default to false
Deprecated
Use fetchMessages(List<String>, PNBoundedPage, Boolean, Boolean, Boolean, Boolean, Boolean) instead
Replace with
import com.pubnub.api.models.consumer.PNBoundedPage
fetchMessages(channels = channels, page = PNBoundedPage(start = start, end = end, limit = maximumPerChannel),includeMeta = includeMeta, includeMessageActions = includeMessageActions, includeMessageType = includeMessageType)Fetch historical messages from 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. For example, you can:
Search for messages starting on the newest end of the timeline.
Search for messages from the oldest end of the timeline.
Page through results by providing a
startORendtime token.Retrieve a slice of the time line by providing both a
startANDendtime token.Limit the number of messages to a specific quantity using the
countparameter.Batch history returns up to 25 messages per channel, on a maximum of 500 channels. Use the start and end timestamps to page through the next batch of messages.
Start & End parameter usage clarity:
If you specify only the
startparameter (withoutend), you will receive messages that are older than and up to thatstarttimetoken.If you specify only the
endparameter (withoutstart), you will receive messages from thatendtimetoken and newer.Specify values for both
startandendparameters to retrieve messages between those timetokens (inclusive of theendvalue).Keep in mind that you will still receive a maximum of 25 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 25 messages meet the timetoken values.
Parameters
Channels to return history messages from.
Specifies the number of historical messages to return per channel. If includeMessageActions is false, then 1 is the default (and maximum) value. Otherwise it's 25.
Timetoken delimiting the start of time slice (exclusive) to pull messages from.
Time token delimiting the end of time slice (inclusive) to pull messages from.
Whether to include message metadata in response. Defaults to false.
Whether to include message actions in response. Defaults to false.