IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMMessageListGetOption

Public Member Functions

 V2TIMMessageListGetOption ()
 
 V2TIMMessageListGetOption (const V2TIMMessageListGetOption &)
 
V2TIMMessageListGetOptionoperator= (const V2TIMMessageListGetOption &)
 
 ~V2TIMMessageListGetOption ()
 

Data Fields

V2TIMMessageGetType getType
 
V2TIMString userID
 
V2TIMString groupID
 
uint32_t count
 
V2TIMElemTypeVector messageTypeList
 
V2TIMMessagelastMsg
 
uint64_t lastMsgSeq
 
int64_t getTimeBegin
 
int64_t getTimePeriod
 
V2TIMUInt64Vector messageSeqList
 

Constructor & Destructor Documentation

◆ V2TIMMessageListGetOption() [1/2]

◆ V2TIMMessageListGetOption() [2/2]

◆ ~V2TIMMessageListGetOption()

Member Function Documentation

◆ operator=()

Field Documentation

◆ getType

Message pulling type (whether to pull older or newer messages from the cloud or local storage)

Attention

If messages are pulled from the cloud, they will be merged with locally stored messages before being returned. If network connection is not available, only locally stored messages will be returned.

About getType, the starting message, and the time range for message pulling:

  • getType indicates the pulling direction: whether to pull older or newer messages.
  • lastMsg and lastMsgSeq indicate the start point for message pulling. For first time pulling, they can be left empty or set to 0.
  • getTimeBegin and getTimePeriod indicate the time range for message pulling. Together with getType, it determines the start and end time for message pulling.
  • If both the starting message and time range are specified, the result returned will be the intersection of messages pulled if only the starting message is specified and the messages pulled if only the time range is specified.
  • If neither the starting message nor time range is specified, the system will pull either older or newer messages (determined by getType) starting from the latest message of the current conversation.
Parameters
getTypePulling type. Valid values: V2TIM_GET_CLOUD_OLDER_MSG, V2TIM_GET_CLOUD_NEWER_MSG, V2TIM_GET_LOCAL_OLDER_MSG, V2TIM_GET_LOCAL_NEWER_MSG

◆ userID

V2TIMString userID

Pull historical one-to-one chat messages.

◆ groupID

V2TIMString groupID

Pull the message history of a group chat.

◆ count

uint32_t count

Number of messages to be pulled.

◆ messageTypeList

V2TIMElemTypeVector messageTypeList

Set the type of messages to pull. This API works only if getType is V2TIM_GET_LOCAL_OLDER_MSG or V2TIM_GET_LOCAL_NEWER_MSG. If null is passed in, all message types will be pulled.

◆ lastMsg

V2TIMMessage* lastMsg

Start message for message pulling

Attention

When one-to-one messages are pulled, only lastMsg can be used to specify the start point for message pulling. If lastMsg is not specified, the Chat SDK will pull starting from the newest message of the conversation.

When group messages are pulled, lastMsg or lastMsgSeq can be used to specify the start point for message pulling:

  • If lastMsg is used to specify the start point for message pulling, the returned message list does not include the message specified by lastMsg.
  • If lastMsgSeq is used to specify the start point for message pulling, the returned message list will include the message specified by lastMsgSeq.
Attention
When group messages are pulled:

If both lastMsg and lastMsgSeq are specified, the Chat SDK will use lastMsg to determine the start point for message pulling.

If neither lastMsg nor lastMsgSeq is specified, there are two cases for determining the start point for message pulling:

  • If the time range for message pulling is specified, the Chat SDK will start pulling from the time point specified by getTimeBegin.
  • If the time range is not specified, the Chat SDK will start pulling from the newest message of the conversation.

◆ lastMsgSeq

uint64_t lastMsgSeq

◆ getTimeBegin

int64_t getTimeBegin

Time range for message pulling

getTimeBegin: indicates the start point of the time range. The default value is 0, indicating to start pulling now. The value can also be a UTC timestamp, in seconds.

getTimePeriod: indicates the length of the time range, in seconds. The default value is 0, indicating that the time range is not limited.

Attention

The direction of the time range is determined by the getType parameter:

If getType is V2TIM_GET_CLOUD_OLDER_MSG/V2TIM_GET_LOCAL_OLDER_MSG, the time range is a time period (determined by getTimePeriod) prior to getTimeBegin.

If getType is V2TIM_GET_CLOUD_NEWER_MSG/V2TIM_GET_LOCAL_NEWER_MSG, the time range is a time period (determined by getTimePeriod) after getTimeBegin.

The value range is a closed range, including the start and end points in time. The relationship between the two is as follows:

  • If older messages are pulled, the time range is [getTimeBegin-getTimePeriod, getTimeBegin].
  • If newer messages are pulled, the time range is [getTimeBegin, getTimeBegin+getTimePeriod].

◆ getTimePeriod

int64_t getTimePeriod

◆ messageSeqList

V2TIMUInt64Vector messageSeqList

Pull the historical messages of a group chat according to the specified sequences (supported in 7.1 and later versions)

Attention
  • This API works only if group messages are pulled.
  • The message sequence comes from the seq field of V2TIMMessage;
  • When getType is set to pull from the cloud, the cloud messages will be merged with local messages. If there is no network connection, local messages will be returned.
  • When getType is set to pull from local storage, local messages will be returned.
  • When getType is set to pull older messages, the message list will be in reverse chronological order, that is, the messages will be sorted in descending order by timestamp
  • When getType is set to pull newer messages, the message list will be in chronological order, that is, the messages will be sorted in ascending order by timestamp.