getHistoryMessageList
Introduction
The advanced method to load the history message list.
Locally stored historical messages are not subject to time limits, but those stored in the cloud are subject to the following time limits:
Trial edition: The free storage period is 7 days and cannot be extended.
Pro edition: The free storage period is 7 days and can be extended.
Ultimate edition: The free storage period is 30 days and can be extended.
Extending the storage period of historical messages is a value-added service. You can log in to the IM console to modify the relevant configuration. For billing details, see Pricing.
Rich media messages (such as images, files, and audios) have the same storage periods as historical messages.
In addition to load historical one-to-one and group messages, this API supports the following advanced features:
Set the source for message loading: loading from the local database or the cloud.
Specify the sequence for message load: loading in reverse chronological order or in chronological order
Specify the message type for local load: text, image, audio, video, file, emoji, group tip, merged, or custom message
For details, you can referring to this document.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
getType | HistoryMsgGetTypeEnum | no | Source and sequence of the message loading, which can be set to local/cloud and reverse chronological order/chronological order respectively. |
userID | string | no | The specified user ID with which to load historical one-to-one messages. |
groupID | string | no | The specified group ID with which to load historical group messages. |
lastMsgSeq | number | no | Sequence of the last message, indicating the message starting from which to load historical messages |
count | number | yes | The amount of the messages loaded once a request, do not set it so large that might affect the speed of processing. |
lastMsgID | string | no | ID of the last message, indicating the message starting from which to load historical messages |
messageTypeList | number[] | no | To specify which types of messages to load, for details, see MessageElemType. |
Returned template
V2TimValueCallback<V2TimMessage[]>
{
code : number
desc : string
data : V2TimMessage[]
}
Return value details
name | type | description |
---|---|---|
code | number | Request result: Error codes. 0 means success. |
desc | string | The description of the error. It will be empty if success. |
data | V2TimMessage[] | The list of messages received. |
Code example
import { TencentImSDKPlugin, HistoryMsgGetTypeEnum } from 'react-native-tim-js';
const getHistoryMessageListRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.getHistoryMessageList(
10,
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
'userID',
'groupID',
-1,
undefined,
[]
);
if (getHistoryMessageListRes.code === 0) {
}