By using the
loadNextPage(completionHandler:) method of a
PreviousMessageListQuery instance which returns a list of
BaseMessage objects, you can retrieve a set number of previous messages in a channel. With the returned list, you can display the past messages in your UI once they have loaded.
Specifies the number of results to return per call. Acceptable values are
Determines whether to sort the retrieved messages in reverse order. If set to
limit property determines how many messages to include in a returned list. The
PreviousMessageListQuery instance itself does pagination of a result set according to the value of the
limit property, and internally manages a token to retrieve the next page in the result set.
Each time the
loadNextPage(completionHandler:) method is called, the instance retrieves a set number of messages in the next page and then updates the token's value to complete the current call and prepare a next call.
If you create a new query instance and call the
loadNextPage(completionHandler:) method, a set number of the most recent messages are retrieved because its token has nothing to do with the previously created instance. So we recommend that you create a single query instance and store it as a member variable for traversing through the entire message history.
Note: Before calling the
loadNextPage(completionHandler:)method again, you should receive a success callback through the