getHistoryMessages

public abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)

获取会话中符合条件的消息列表。

返回的消息中不包含 oldestMessageId 对应那条消息,如果会话中的消息数量小于参数 count 的值,会将该会话中的所有消息返回。 如:oldestMessageId 为 10,count 为 2,会返回 messageId 为 9 和 8 的 Message 对象列表。

Parameters

conversationType

会话类型 io.rong.imlib.model.Conversation.ConversationType

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id 。

objectName

消息类型标识。

oldestMessageId

最后一条消息的 Id,获取此消息之前的 count 条消息,没有消息第一次调用应设置为:-1。

count

要获取的消息数量

callback

获取历史消息的回调,按照时间顺序从新到旧排列。


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int baseMessageId, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)

获取会话中符合条件的消息列表。

如:获取 messageId 为 22 的之前的 10条 图片消息,则相应参数为 getHistoryMessages(conversationType, targetId, "RC:ImgMsg", 22, 10, true, resultCallback)。

Parameters

conversationType

会话类型 io.rong.imlib.model.Conversation.ConversationType

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id。

objectName

消息类型标识。如 RC:TxtMsg,RC:ImgMsg,RC:VcMsg 等 value 。

baseMessageId

起始消息 id。

count

需要获取的消息数量。

direction

要获取的消息相对于 baseMessageId 的方向 以指定的 baseMessageId 作为获取的起始点,时间早于 baseMessageId 则为 FRONT,晚于则为 BEHIND。

callback

获取历史消息的回调,按照时间顺序从新到旧排列。


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, List<String> objectNames, long timestamp, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)

获取会话中符合条件的消息列表。

如: 要获取 messageId 为 22 的之前的 10 条图片消息,和文字消息 objectNames 为字符串 List

objectNames.add("RC:ImgMsg");
objectNames.add("RC:TxtMsg");

则相应参数为 getHistoryMessages(conversationType, targetId, objectNames, 22, 10, true, resultCallback)。

Parameters

conversationType

会话类型 io.rong.imlib.model.Conversation.ConversationType

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id。

objectNames

消息类型标识 List。如 RC:TxtMsg,RC:ImgMsg,RC:VcMsg 等构成的 List。

timestamp

当前消息时间戳。

count

需要获取的消息数量。

direction

要获取的消息相对于当前消息的方向 io.rong.imlib.RongCommonDefine.GetMessageDirection 以当前消息作为起始点,时间早于当前消息则为 FRONT,否则为 BEHIND。

callback

获取历史消息的回调,按照时间顺序从新到旧排列。


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)

获取会话中,从指定消息之前、指定数量的、指定消息类型的最新消息实体。

Parameters

conversationType

会话类型,参考 Conversation.ConversationType 。

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id。

oldestMessageId

最后一条消息的 id。获取此消息之前的 count 条消息,没有消息第一次调用应设置为 -1。

count

要获取的消息数量。

callback

获取历史消息的回调,按照时间顺序从新到旧排列。


public abstract void getHistoryMessages(ConversationType conversationType, String targetId, long sentTime, int before, int after, RongIMClient.ResultCallback<List<Message>> resultCallback)

在会话中搜索指定消息的前 before 数量和 after 数量的消息。

返回的消息列表中会包含指定的消息。消息列表时间顺序从新到旧。

Parameters

conversationType

指定的会话类型。

targetId

指定的会话 id。

sentTime

指定消息的发送时间,不能为 0。

before

指定消息的前部分消息数量。

after

指定消息的后部分消息数量。

resultCallback

搜索结果回调。

上拉加载时,返回数据中包含当前消息;例:当前消息 id 为 500, before = 0 after = 10,返回 510 - 500 ,按消息 id 倒序。


@Deprecated()
public abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count)

Deprecated

获取会话中符合条件的消息列表。

Return

历史消息,按照时间顺序从新到旧排列。

Deprecated

已废弃,建议使用 getHistoryMessagesgetHistoryMessages 异步方法。

Parameters

conversationType

会话类型 io.rong.imlib.model.Conversation.ConversationType

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id。

oldestMessageId

最后一条消息的 id,获取此消息之前的 count 条消息,没有消息第一次调用应设置为:-1。

count

要获取的消息数量。


@Deprecated()
public abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count)

Deprecated

获取会话中符合条件的消息列表。

Return

历史消息,按照时间顺序从新到旧排列。

Deprecated

已废弃,建议使用 getHistoryMessagesgetHistoryMessages 异步方法。

Parameters

conversationType

会话类型 io.rong.imlib.model.Conversation.ConversationType

targetId

会话 id。根据不同的 conversationType,可能是用户 id、讨论组 id、群组 id。

objectName

消息类型标识。

oldestMessageId

最后一条消息的 id,获取此消息之前的 count 条消息,没有消息第一次调用应设置为:-1。

count

要获取的消息数量。