load() method of a
PreviousMessageListQuery instance returns a list of
BaseMessage objects. Using this method, you can retrieve previous messages in a specific channel. If you want to include the replies of the target messages in the results, change the value of properties in the
For group channels, you can decide whether a user can see messages sent prior to the user joining the channel. To allow new users to view the message history of the group channels they joined, you can turn on Chat history by going to Settings > Chat > Channels > Group channels on Sendbird Dashboard. If this option is turned off, new users can't see messages sent prior to joining the group channel. The table below shows a list of parameters in
Specifies the number of results returned per call. Acceptable values are
Determines whether to sort the retrieved messages in reverse order. If set to
Determines whether to include the thread information of the messages in the results when the results contain parent messages. (Default:
Specifies the type of message to include in the results.
Determines whether to include the thread information of the messages in the result. (Default:
Determines whether to include the information of the parent messages in the result. (Default:
limit property indicates how many messages should be included in a returned list. A query instance itself does the 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
load() method is called, the instance retrieves a set number of messages in the next page and then updates the value of the token to complete the current call and prepare the next call.
If you create a new query instance and call the
load() method, a set number of the most recently sent 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.
Before calling the
load() method again, you must receive a success callback from the server.
The following table shows all the supported parameters you can use as filters for
PreviousMessageListQuery to search for messages you want to retrieve. You can use any parameters in a similar fashion with the sample code above.
Messages with the specified message type. Specifying the
Messages with the specified custom message type. Specifying the
Messages that are sent by the specified users. Specifying the