chat.getMessageList(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
conversationID | String | Conversation ID, which consists of: C2C${userID} (for one-to-one chats) GROUP${groupID} (for group chats) GROUP${topicID} (topic) @TIM#SYSTEM (system notification conversation) |
nextReqMessageID | String | undefined | Message ID used for the subsequent paged pull. Leave this field empty for the first pull and enter its the value returned by the getMessageList API for the subsequent pull. |
Promise
// Pull the message list for the first time when a conversation is openedlet promise = chat.getMessageList({conversationID: 'C2Ctest'});promise.then(function(imResponse) {const messageList = imResponse.data.messageList; // Message list// This parameter must be passed in for the next pull by page.const nextReqMessageID = imResponse.data.nextReqMessageID;// It indicates whether all messages have been pulled.const isCompleted = imResponse.data.isCompleted;});
// Pull down the message list to view more messageslet promise = chat.getMessageList({conversationID: 'C2Ctest', nextReqMessageID});promise.then(function(imResponse) {const messageList = imResponse.data.messageList; // Message list// This parameter must be passed in for the next pull by page.const nextReqMessageID = imResponse.data.nextReqMessageID;// It indicates whether all messages have been pulled.const isCompleted = imResponse.data.isCompleted;});
chat.getMessageListHopping(options);
options
parameter is of the Object
type. It contains the following attribute values:Name | Type | Description |
conversationID | String | Conversation ID, which consists of: C2C${userID} (for one-to-one chats) GROUP${groupID} (for group chats) GROUP${topicID} (topic). |
sequence | Number | undefined | sequence of the message starting from which to pull roaming group messages |
time | Number | undefined | Server time of the message, starting from which to pull roaming one-to-one messages |
direction | Number | Message pull direction, which defaults to 0 .0: pull in reverse chronological order to get older messages; 1: pull in chronological order to get recent messages |
count | Number | undefined | Number of messages to be pulled. It defaults to 15, which is also the maximum value, indicating that up to 15 messages can be pulled and returned at a time. |
Promise
// Pull roaming group messages by sequence.// `direction`: 0: pull in reverse chronological order to get older messages// 1: pull in chronological order to get recent messageslet promise = chat.getMessageListHopping({conversationID: 'GROUPtest',sequence: 100,count: 15,direction: 0});promise.then(function(imResponse) {const messageList = imResponse.data.messageList; // Message list});
// Pull roaming one-to-one messages by time range.// `direction`: 0: pull in reverse chronological order to get older messages// 1: pull in chronological order to get recent messageslet promise = chat.getMessageListHopping({conversationID: 'C2Ctest',time: xxx,count: 15,direction: 0});promise.then(function(imResponse) {const messageList = imResponse.data.messageList; // Message list});
Was this page helpful?