TencentImSDKPlugin.v2TIMManager.getMessageManager() class.// Pull historical one-to-one messages// Set `lastMsgID` to `null` for the first pull// `lastMsgID` can be the ID of the last message in the returned message list for the second pull.TencentImSDKPlugin.v2TIMManager.getMessageManager().getC2CHistoryMessageList(userID: "userId",count: 10,lastMsgID: null,);
// Pull historical group messages// Set `lastMsgID` to `null` for the first pull// `lastMsgID` can be the ID of the last message in the returned message list for the second pull.TencentImSDKPlugin.v2TIMManager.getMessageManager().getGroupHistoryMessageList(groupID: "groupID",count: 10,lastMsgID: null,);
getHistoryMessageList (details).// Pull historical one-to-one messages// Set `lastMsgID` to `null` for the first pull// `lastMsgID` can be the ID of the last message in the returned message list for the second pull.V2TimValueCallback<List<V2TimMessage>> getHistoryMessageListRes =await TencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(getType: HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG, // Source and sequence of the message pulluserID: "userID", // To pull one-to-one messages with a certain user, you need to specify only the `userID`.groupID: "groupID", // To pull group messages from a certain group, you need to specify only the `groupID`.count: 10, // Number of messages pulledlastMsgID: null, // ID of the first message for pulling// This field can be used only for group chats.// If `lastMsgSeq` is set as the start point for message, the message will be included in the returned message list.// If both `lastMsg` and `lastMsgSeq` are specified, the SDK will use `lastMsg`.// If neither `lastMsg` nor `lastMsgSeq` is specified, the start point for pull will be determined based on whether the `getTimeBegin` is set. If yes, the set range will be used as the start point; if no, the latest message will be used as the start point.lastMsgSeq: -1,messageTypeList: [], // Used to filter historical message information attributes. If this field is left empty, all attributes will be pulled.);if (getHistoryMessageListRes.code == 0) {// Obtained successfully}
Parameter | Description | Valid for One-to-One Chat | Valid for Group Chat | Required | Remarks |
getType | Source and sequence of the message pull, which can be set to local/cloud and reverse chronological order/chronological order respectively. | YES | YES | YES | When the pull source is set to the cloud, the local message list and cloud message list will be combined and returned. If there is no network connection, the local message list will be returned. |
userID | The specified user ID with which to pull historical one-to-one messages | YES | NO | NO | To pull one-to-one messages, you need to specify only the userID. |
groupID | The specified group ID with which to pull historical group messages | NO | YES | NO | To pull group messages, you need to specify only the groupID. |
count | Number of messages per pull | YES | YES | YES | We recommend you set it to 20 for iOS/Android clients; otherwise, the pull speed may be affected. For web clients, the maximum value allowed is 15. |
lastMsgID | ID of the last message, indicating the message starting from which to pull historical messages | YES | YES | NO | 1. It can be used for both one-to-one and group chats. 2. If it is set as the start point for the message pull, the message will not be included in the returned message list. 3. If it is left empty, the latest message in the conversation will be used as the start point for pull. |
lastMsgSeq | seq of the last message, indicating the message starting from which to pull historical messages | NO | YES | NO | 1. It can be used only for group chats. 2. If it is set as the start point for the message pull, the message will be included in the returned message list. 3. If both lastMsg and lastMsgSeq are specified, the SDK will use lastMsg. 4. If neither lastMsg nor lastMsgSeq is specified, the start point for pull will be determined based on whether the getTimeBegin is set. If yes, the set range will be used as the start point; if no, the latest message will be used as the start point. |
lastMsg and count.lastMsg and count. For the first pull, lastMsg can be left empty, which indicates that the last message in the returned message list will be used as the lastMsg to pull data of the next page.lastMsg is left empty, the SDK will return historical messages starting from the latest message by default.lastMsg is set, it is not included in the returned message list.count to 20 for pagination.lastMsgSeq for the subsequent pull, as the corresponding message will be included in the returned message list.getType to pull only local messages:getType is set to V2TIM_GET_LOCAL_OLDER_MSG, locally stored messages will be pulled in reverse chronological order.getType is set to V2TIM_GET_LOCAL_NEWER_MSG, locally stored messages will be pulled in chronological order.TencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(count: 10,getType: HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,userID: "userID",);
sequence as the lastMsgSeq and use the advanced API to pull messages.// Get the `sequence` of the group @ messageint atSequence = 1081;// Pull the group @ message and earlier messagesTencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(count: 20, // Pull 20 messagesgetType: HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG, // Pull messages earlier than the group @ messagelastMsgSeq: atSequence,// Start the pull from the group @ message, which is included in the pull listgroupID: "groupID" // Pull group messages);// Pull messages later than the group @ messageTencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(count: 20, // Pull 20 messagesgetType: HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_NEWER_MSG, // Pull messages later than the group @ messagelastMsgSeq: atSequence,// Start the pull from the group @ message, which is included in the pull listgroupID: "groupID" // Pull group messages);
getType is set to pull cloud historical messages and the number of messages to be pulled is set to x, the SDK will pull x messages from the cloud.onlineUserOnly to YES/true when sending messages.getType is set to pull cloud historical messages and the number of messages is count, the SDK will perform the following operations:count messages from the local database.count messages from the cloud and filter out invalid messages such as deleted messages. If the number is smaller than count, the paged pull will be triggered.count messages from the combined message list.getGroupMembersInfo API (details).count). Feedback