NIMSDK-AOS
9.11.0
|
云信消息服务接口 更多...
Public 成员函数 | |
InvocationFuture< Void > | sendMessage (IMMessage msg, boolean resend) |
发送消息。 如果需要更新发送进度,请调用MsgServiceObserve#observeMsgStatus(com.netease.nimlib.sdk.Observer, boolean) 更多... | |
InvocationFuture< Void > | replyMessage (IMMessage msg, IMMessage replyMsg, boolean resend) |
回复消息。 如果需要更新发送进度,请调用MsgServiceObserve#observeMsgStatus(com.netease.nimlib.sdk.Observer, boolean) 更多... | |
AbortableFuture< FileAttachment > | sendFile (FileAttachment attachment) |
上传文件附件 更多... | |
InvocationFuture< Void > | insertLocalMessage (IMMessage msg, String fromAccount) |
插入消息到本地数据库,且通知更新UI界面,但不发送到服务器端。发送一条可设置他人为发送方的本地消息给自己。 该接口将消息保存到数据库后,会通知到UI,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。 更多... | |
InvocationFuture< Void > | saveMessageToLocal (IMMessage msg, boolean notify) |
保存消息到本地数据库,但不发送到服务器端。用于第三方APP保存本地提醒一类的消息。 该接口将消息保存到数据库后,如果需要通知到UI,可将notify设置为true,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。 更多... | |
InvocationFuture< Void > | saveMessageToLocalEx (IMMessage msg, boolean notify, long time) |
保存消息到本地数据库,但不发送到服务器端。可设置保存消息的时间 用于第三方APP保存本地提醒一类的消息。 该接口将消息保存到数据库后,如果需要通知到UI,可将notify设置为true,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。 更多... | |
AbortableFuture< Void > | downloadAttachment (IMMessage msg, boolean thumb) |
正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载 更多... | |
List< IMMessage > | queryMessageListByUuidBlock (List< String > uuids) |
通过uuid批量获取IMMessage(同步版本) 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListByUuid (List< String > uuids) |
通过uuid批量获取IMMessage 更多... | |
List< IMMessage > | queryMessageListByServerIdBlock (List< String > serverIds) |
通过 Server ID 批量获取IMMessage(同步版本) 注意:一个ServerId可能对应多条消息 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListByType (MsgTypeEnum msgTypeEnum, IMMessage anchor, int limit) |
通过消息类型从本地消息数据库中查询消息历史。查询范围由msgTypeEnum参数和anchor的sessionId决定 该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListByType (MsgTypeEnum msgTypeEnum, Long maxTime, int limit) |
通过消息类型查询所有消息记录, 更多... | |
List< IMMessage > | queryMessageListBySubtypeBlock (MsgTypeEnum msgTypeEnum, IMMessage anchor, int limit, int subtype) |
通过消息子类型查询本地消息记录(同步版本) 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListBySubtype (MsgTypeEnum msgTypeEnum, IMMessage anchor, int limit, int subtype) |
通过消息子类型查询本地消息记录(异步版本) 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageList (String account, SessionTypeEnum sessionType, long offset, int limit) |
从本地消息数据库中查询消息历史。 按照消息记录时间先后倒序查询,查询条件为 "ORDER BY time desc limit ${limit} offset ${offset}"。 注意:返回结果的消息历史列表排列顺序也为倒序:即时间大的消息在前,时间小的消息在后。 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListEx (IMMessage anchor, QueryDirectionEnum direction, int limit, boolean asc) |
根据锚点和方向从本地消息数据库中查询消息历史。 根据提供的方向(direct),查询比anchor更老(QUERY_OLD)或更新(QUERY_NEW)的最靠近anchor的limit条数据。 调用者可使用asc参数指定结果排序规则,结果使用time作为排序字段。 注意:查询结果不包含锚点。 更多... | |
List< IMMessage > | queryMessageListExBlock (IMMessage anchor, QueryDirectionEnum direction, int limit, boolean asc) |
根据锚点和方向从本地消息数据库中查询消息历史。(同步函数) 根据提供的方向(direct),查询比anchor更老(QUERY_OLD)或更新(QUERY_NEW)的最靠近anchor的limit条数据。 调用者可使用asc参数指定结果排序规则,结果使用time作为排序字段。 注意:查询结果不包含锚点。 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListExTime (IMMessage anchor, long toTime, QueryDirectionEnum direction, int limit) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询消息历史。 根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。 查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。 查询结果排序规则:direction 为 QUERY_OLD 时 按时间降序排列,direction 为 QUERY_NEW 时按照时间升序排列。 注意:查询结果不包含锚点。 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListByTypes (List< MsgTypeEnum > types, IMMessage anchor, long toTime, QueryDirectionEnum direction, int limit, boolean asc) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询指定消息类型的消息历史。 根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。 查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。 查询结果排序规则:如果asc为true,结果按照时间升序排列,如果为false,按照时间降序排列 注意:查询结果不包含锚点。 更多... | |
InvocationFuture< List< IMMessage > > | queryMessageListByTypesV2 (List< MsgTypeEnum > types, IMMessage anchor, long toTime, QueryDirectionEnum direction, int limit, boolean asc) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询指定消息类型的消息历史。 根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。 查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。 查询结果排序规则:如果asc为true,结果按照时间升序排列,如果为false,按照时间降序排列 注意:查询结果不包含锚点。 更多... | |
InvocationFuture< Long > | queryRoamMsgHasMoreTime (String sessionId, SessionTypeEnum sessionType) |
获取是否有更多漫游消息标记的时间戳,如果没有,回调0L 更多... | |
long | queryRoamMsgHasMoreTimeBlock (String sessionId, SessionTypeEnum sessionType) |
获取是否有更多漫游消息标记的时间戳,如果没有,回调0L(同步接口) 更多... | |
InvocationFuture< Long > | queryRoamMsgHasMoreTagServerId (String sessionId, SessionTypeEnum sessionType) |
获取是否有更多漫游消息标记的serverid,如果没有,回调0L 更多... | |
long | queryRoamMsgHasMoreTagServerIdBlock (String sessionId, SessionTypeEnum sessionType) |
获取是否有更多漫游消息标记的serverid,如果没有,回调0L(同步接口) 更多... | |
InvocationFuture< List< IMMessage > > | pullHistoryById (List< MessageKey > msgKeyList, boolean persist) |
根据消息ID等信息从服务器批量查询历史消息 更多... | |
IMMessage | queryLastMessage (String account, SessionTypeEnum sessionType) |
查询同指定用户的最近一条消息 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistory (IMMessage anchor, int limit, boolean persist) |
从服务器拉取消息历史记录。该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。 当已经查询到头时,返回的结果列表的size可能会比limit小 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistory (IMMessage anchor, int limit, boolean persist, boolean persistClear) |
从服务器拉取消息历史记录。该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。 当已经查询到头时,返回的结果列表的size可能会比limit小 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryEx (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, boolean persist) |
从服务器拉取消息历史记录。以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。 查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryExType (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, MsgTypeEnum[] msgTypes) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryExType (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, MsgTypeEnum[] msgTypes, boolean persist) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果是否保存到本地消息数据库。 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryExType (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, MsgTypeEnum[] msgTypes, boolean persist, boolean persistClear) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryExType (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, MsgTypeEnum[] msgTypes, boolean persist, boolean persistClear, IMMessageFilter customFilter) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryExType (IMMessage anchor, long toTime, int limit, QueryDirectionEnum direction, MsgTypeEnum[] msgTypes, boolean persist, boolean persistClear, IMMessageFilter customFilter, boolean updateUnread) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistory (MsgFullKeywordSearchConfig config) |
云端历史消息全文检索 更多... | |
InvocationFuture< List< IMMessage > > | pullMessageHistoryOrderByTime (MsgTimingFullKeywordSearchConfig config) |
云端历史消息全文检索(按时间排序,不按会话分组) 更多... | |
InvocationFuture< GetMessagesDynamicallyResult > | getMessagesDynamically (GetMessagesDynamicallyParam param) |
动态途径获取消息,默认从本地获取,动态能力需要开通功能,并在同步完成后生效 更多... | |
InvocationFuture< List< IMMessage > > | searchMessageHistory (String keyword, List< String > fromAccounts, IMMessage anchor, int limit) |
从本地消息数据库搜索消息历史。查询范围由anchor的sessionId和sessionType决定。 以锚点anchor作为起始点开始查询,返回最多limit条匹配key的记录。 该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。 由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。 如果提供的fromAccounts参数不为空,那么anchor对应的会话(sessionId和sessionType)的消息记录中, 凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。 注意:搜索结果不包含anchor 更多... | |
InvocationFuture< List< IMMessage > > | searchMessageHistory (String keyword, List< String > fromAccounts, IMMessage anchor, QueryDirectionEnum direction, int limit) |
从本地消息数据库搜索消息历史。查询范围由anchor的sessionId和sessionType决定。 该接口查询方向为从后往前。以锚点anchor作为起始点开始查询,返回最多limit条匹配key的记录。 该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。 由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。 如果提供的fromAccounts参数不为空,那么anchor对应的会话(sessionId和sessionType)的消息记录中, 凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。 注意:搜索结果不包含anchor 更多... | |
InvocationFuture< List< IMMessage > > | searchAllMessageHistory (String keyword, List< String > fromAccounts, long time, int limit) |
从本地消息数据库搜索消息历史。 该接口查询方向以某个时间点为基准从后往前,返回最多limit条匹配key的记录。 该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。 由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。 如果提供的fromAccounts参数不为空,那么凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。 更多... | |
InvocationFuture< List< IMMessage > > | searchMessage (SessionTypeEnum sessionType, String sessionId, MsgSearchOption option) |
从本地消息数据库搜索消息历史。 搜索将返回:时间在 (startTime,endTime) 之间,消息类型为指定类型,且匹配搜索内容或消息发起者列表的一定数量的消息。 更多... | |
InvocationFuture< List< IMMessage > > | searchAllMessage (MsgSearchOption option) |
从本地消息数据库全局搜索消息历史。 搜索将返回:时间在 (startTime,endTime) 之间,消息类型为指定类型,且匹配搜索内容或消息发起者列表的一定数量的消息。 更多... | |
InvocationFuture< List< MsgIndexRecord > > | searchAllSession (String query, int limit) |
检索所有会话,返回每个会话与检索串匹配的消息数及最近一条匹配的消息记录。(异步函数) 更多... | |
List< MsgIndexRecord > | searchAllSessionBlock (String query, int limit) |
检索所有会话,返回每个会话与检索串匹配的消息数及最近一条匹配的消息记录。(同步函數) 更多... | |
InvocationFuture< List< MsgIndexRecord > > | searchSession (String query, SessionTypeEnum sessionType, String sessionId) |
检索指定的会话,返回该会话中与检索串匹配的所有消息记录。(异步函数) 更多... | |
List< MsgIndexRecord > | searchSessionBlock (String query, SessionTypeEnum sessionType, String sessionId) |
检索指定的会话,返回该会话中与检索串匹配的所有消息记录。(同步函数) 更多... | |
void | deleteChattingHistory (IMMessage message) |
删除一条消息记录,并在数据库记录此操作 从云端拉取消息时,如果本地有删除该消息的操作记录,则该消息不会入库 删除标记会被清除标记覆盖 更多... | |
void | deleteChattingHistory (IMMessage message, boolean ignore) |
删除一条消息记录 更多... | |
void | deleteChattingHistory (List< IMMessage > msgList, boolean ignore) |
删除多条消息记录 更多... | |
void | clearChattingHistory (String account, SessionTypeEnum sessionType) |
清除与指定用户的所有消息记录,且不在数据库记录此次操作 更多... | |
void | clearChattingHistory (String account, SessionTypeEnum sessionType, boolean ignore) |
清除与指定用户的所有本地消息记录 更多... | |
InvocationFuture< Void > | clearMsgDatabase (boolean clearRecent) |
清空消息数据库的所有消息记录。 可选择是否要同时清空最近联系人列表数据库。 若最近联系人列表也被清空,会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知 更多... | |
InvocationFuture< Long > | deleteMsgSelf (IMMessage msg, String ext) |
单向删除一条消息 更多... | |
InvocationFuture< Long > | deleteMsgSelf (List< IMMessage > msgList, String ext) |
单向删除多条消息 更多... | |
boolean | everBeenDeleted (IMMessage message) |
消息是否曾被从本地删除 更多... | |
void | setChattingAccount (String account, SessionTypeEnum sessionType) |
设置当前正在聊天的对象。设置后会影响内建的消息提醒。如果有新消息到达,且消息来源是正在聊天的对象,将不会有消息提醒。 调用该接口还会附带调用clearUnreadCount(String, SessionTypeEnum),将正在聊天对象的未读数清零。 更多... | |
int | getTotalUnreadCount () |
获取未读数总数 更多... | |
int | getTotalUnreadCount (boolean notify) |
获取未读数总数 更多... | |
int | getUnreadCountBySessionType (SessionTypeEnum sessionType) |
获取指定会话类型的总未读数 更多... | |
InvocationFuture< List< IMMessage > > | queryUnreadMessageList (String sessionId, SessionTypeEnum sessionType) |
根据会话ID和会话类型查找未读消息列表 更多... | |
List< IMMessage > | queryUnreadMessageListBlock (String sessionId, SessionTypeEnum sessionType) |
根据会话ID和会话类型查找未读消息列表(同步版本) 更多... | |
InvocationFuture< Void > | clearUnreadCount (String account, SessionTypeEnum sessionType) |
将指定最近联系人的未读数清零(标记已读)。 调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知 更多... | |
InvocationFuture< List< SessionAckInfo > > | clearUnreadCount (List< Pair< String, SessionTypeEnum >> sessionKeyList) |
将指定最近联系人的未读数清零(标记已读)。 调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知 更多... | |
InvocationFuture< List< SessionAckInfo > > | clearUnreadCount (SessionTypeEnum sessionType) |
将指定会话类型的未读数清零(标记已读)。 调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知 更多... | |
void | clearAllUnreadCount () |
将所有联系人的未读数清零(标记已读) 调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知 更多... | |
InvocationFuture< Void > | sendMessageReceipt (String sessionId, IMMessage message) |
发送P2P消息已读回执 更多... | |
void | updateIMMessageStatus (IMMessage message) |
更新消息记录的状态。可更新: 消息状态 IMMessage#getStatus() 不为 null 时更新 附件状态 IMMessage#getAttachStatus() 不为 null 时更新 附件内容 IMMessage#getAttachment() 不为 null 时更新 更多... | |
void | updateIMMessage (IMMessage message) |
更新消息。目前只能更新本地扩展字段LocalExtension 更多... | |
void | registerCustomAttachmentParser (MsgAttachmentParser customParser) |
如果第三方app需要自定义的附件消息类型,再次注册自己的附件解析器。 客户自定义的消息类型为com.netease.nimlib.sdk.msg.constant.MsgTypeEnum#custom 自定义附件类型须继承自MsgAttachment。 更多... | |
InvocationFuture< Void > | sendCustomNotification (CustomNotification notification) |
发送一条指令消息。 由于SDK仅负责透传该消息,因此不会记录指令消息状态,但可以设置回调函数监听发送结果。 更多... | |
InvocationFuture< List< RecentContact > > | queryRecentContacts () |
查询最近联系人会话列表数据 更多... | |
List< RecentContact > | queryRecentContactsBlock () |
查询最近联系人会话列表数据(同步版本) 更多... | |
InvocationFuture< List< RecentContact > > | queryRecentContacts (int limit) |
查询最近联系人会话列表数据, 可以设置limit, 防止本地会话过多时,导致第一次加载慢 更多... | |
InvocationFuture< List< RecentContact > > | queryRecentContacts (RecentContact anchor, QueryDirectionEnum direction, int limit) |
查询最近联系人会话列表数据,可按时间逆序或者正序查询指定数量的最新会话列表数据 更多... | |
List< RecentContact > | queryRecentContactsBlock (int limit) |
查询最近联系人会话列表数据(同步版本),可以设置limit, 防止本地会话过多时,导致第一次加载慢 更多... | |
List< RecentContact > | queryRecentContactsBlock (RecentContact anchor, QueryDirectionEnum direction, int limit) |
查询最近联系人会话列表数据(同步版本),可按时间逆序或者正序查询指定数量的最新会话列表数据 更多... | |
InvocationFuture< List< RecentContact > > | queryRecentContacts (MsgTypeEnum filterMsgType) |
查询联系人最近会话列表数据, 最近一条不等于过滤消息类型, eg: 需要过滤MsgTypeEnum.notification, 则传入改type note :该方法返回未读为全量消息未读 更多... | |
List< RecentContact > | queryRecentContactsBlock (MsgTypeEnum filterMsgType) |
查询联系人最近会话列表数据(同步版本), 最近一条不等于过滤消息类型, 该方法可能会执行较长时间,建议使用异步版本, note :该方法返回未读为全量消息未读 更多... | |
InvocationFuture< List< RecentContact > > | queryRecentContacts (Set< MsgTypeEnum > filterMsgTypeSet) |
查询联系人最近会话列表数据, 最近一条不在过滤消息类型中, eg: 需要过滤MsgTypeEnum.notification, 则传入改type note :该方法返回未读为全量消息未读 更多... | |
List< RecentContact > | queryRecentContactsBlock (Set< MsgTypeEnum > filterMsgTypeSet) |
查询联系人最近会话列表数据(同步版本), 最近一条不在过滤消息类型中, 该方法可能会执行较长时间,建议使用异步版本, note :该方法返回未读为全量消息未读 更多... | |
void | updateRecent (RecentContact recent) |
更新一条最近联系人会话的属性。 如果想收到MsgServiceObserve#observeRecentContact(Observer, boolean)的通知, 可使用MsgService#updateRecentAndNotify(RecentContact) 目前可设置的属性有:tag, extension 更多... | |
void | updateRecentAndNotify (RecentContact recent) |
更新一条最近联系人会话的属性,并会触发MsgServiceObserve#observeRecentContact(Observer, boolean)的通知 。 如果仅仅是想更新最近联系人会话但不想收到通知, 可使用MsgService#updateRecent(RecentContact) 。 目前可设置的属性有:tag , extension。 更多... | |
void | updateRecentByMessage (IMMessage message, boolean needNotify) |
通过消息更新一条最近联系人会话。 如果原来有这个会话,会保留原来的未读数以及tag相关属性 如果消息的时间比原来的会话小的话,则不会更新 更多... | |
void | updateRoamMsgHasMoreTag (IMMessage newTag) |
更新是否有更多漫游消息的标记 更多... | |
void | deleteRecentContact (RecentContact recent) |
从最近联系人会话列表中删除一项,既删本地也删漫游。 调用这个接口删除数据后,不会引发观察者通知。 更多... | |
void | deleteRecentContact2 (String account, SessionTypeEnum sessionType) |
删除最近联系人记录,既删本地也删漫游。 调用该接口后,会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知 更多... | |
InvocationFuture< Void > | deleteRoamingRecentContact (String contactId, SessionTypeEnum sessionTypeEnum) |
删除指定最近联系人的漫游消息。 不删除本地消息,但如果在其他端登录,当前时间点该会话已经产生的消息不漫游。 更多... | |
InvocationFuture< Void > | deleteRecentContact (String account, SessionTypeEnum sessionType, DeleteTypeEnum deleteType, boolean sendAck) |
删除最近联系人记录。 调用该接口后,不会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知 更多... | |
void | deleteRoamMsgHasMoreTag (String sessionId, SessionTypeEnum sessionType) |
删除是否有更多漫游的标记 更多... | |
AbortableFuture< String > | transVoiceToText (String voiceUrl, String path, long duration) |
语音转文字 更多... | |
AbortableFuture< String > | transVoiceToTextAtScene (String voiceUrl, String path, long duration, String sceneKey) |
语音转文字并指定上传文件的场景 更多... | |
AbortableFuture< String > | transVoiceToTextEnableForce (String voiceUrl, String path, long duration, String sceneKey, boolean enableForceUploadFile) |
语音转文字并指定上传文件的场景以及是否要强制重新上传文件 更多... | |
InvocationFuture< ArrayList< IMMessage > > | searchRoamingMsg (String otherAccid, long fromTime, long endTime, String keyword, int limit, boolean reverse) |
云端聊天记录关键词查询 更多... | |
void | registerIMMessageFilter (IMMessageFilter filter) |
注册通知消息过滤器 更多... | |
void | registerShouldShowNotificationWhenRevokeFilter (ShowNotificationWhenRevokeFilter filter) |
注册是否在撤回消息时展示通知的过滤器 更多... | |
InvocationFuture< Void > | revokeMessage (IMMessage message) |
消息撤回 ,默认没有第三方推送(包括IOS平台的推送),参考MsgService#revokeMessageEx(IMMessage, String, Map) 更多... | |
InvocationFuture< Void > | revokeMessageEx (IMMessage message, String customApnsText, Map< String, Object > pushPayload) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送),如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on) 更多... | |
InvocationFuture< Void > | revokeMessage (IMMessage message, String customApnsText, Map< String, Object > pushPayload, boolean shouldNotifyBeCount) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on) 更多... | |
InvocationFuture< Void > | revokeMessage (IMMessage message, String customApnsText, Map< String, Object > pushPayload, boolean shouldNotifyBeCount, String postscript) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on) 更多... | |
InvocationFuture< Void > | revokeMessage (IMMessage message, String customApnsText, Map< String, Object > pushPayload, boolean shouldNotifyBeCount, String postscript, String attach) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on) 更多... | |
InvocationFuture< Void > | importRecentSessions (List< Pair< String, SessionTypeEnum >> sessions) |
导入最近会话,批量导入,仅支持 contactId 和 sessionType 两个字段 更多... | |
LocalAntiSpamResult | checkLocalAntiSpam (String content, String replacement) |
检验本地反垃圾词库 更多... | |
RecentContact | createEmptyRecentContact (String contactId, SessionTypeEnum sessionType, long tag, long time, boolean saveToDB) |
创建一条空的联系人会话 更多... | |
RecentContact | createEmptyRecentContact (String contactId, SessionTypeEnum sessionType, long tag, long time, boolean saveToDB, boolean withLastMsg) |
创建一条空的联系人会话 更多... | |
RecentContact | queryRecentContact (String contactId, SessionTypeEnum sessionType) |
根据 contactId 与 sessionType 从db 中查询联系人会话记录。 更多... | |
InvocationFuture< Void > | cancelUploadAttachment (IMMessage imMessage) |
取消上传消息附件(图片、视频、文件类型的),如果附件已经上传成功,操作将会失败 。 如果成功取消了附件的上传,那么相应的消息会发送失败,对应的消息状态是MsgStatusEnum#fail,附件状态是AttachStatusEnum#cancel 注意:此操作暂时不支持聊天室 更多... | |
AbortableFuture< Void > | exportAllMessage (IMsgExportProcessor exportProcessor, boolean safeMode) |
导出本地db 的所有消息并上传给服务器,对应于导入消息的操作(常用于端到端的历史消息牵移),如果有云端消息记录,不建议使用这个接口 导入参考MsgService#importAllMessage(IMsgImportProcessor, boolean safeMode) 只会导出以下类型的消息:文本消息 、图片消息、 音频消息、 视频消息 、文件消息、自定义消息 整个过程如下: step1 : 消息转换成文件 step2 : 压缩文件(用户自定义过程) step3 : 加密文件(用户自定义过程) step4 : 上传文件 错误码: DB中没有数据 : MigrationConstant#EXPORT_ERR_DB_EMPTY 本地消息格式化失败 : MigrationConstant#EXPORT_ERR_LOCAL_FORMAT 文件压缩失败(用户自定义过程) : MigrationConstant#EXPORT_ERR_USER_CUSTOM_ZIP 消息导出时,文件加密失败(用户自定义过程) : MigrationConstant#EXPORT_ERR_USER_CUSTOM_ENCRYPT 上传文件失败 : MigrationConstant#EXPORT_ERR_UPLOAD_FILE 消息导出时,本地有消息,但是都被过滤了 : MigrationConstant#EXPORT_ERR_EMPTY_AFTER_FILTER 更多... | |
AbortableFuture< Void > | importAllMessage (IMsgImportProcessor iMsgImportProcessor, boolean safeMode) |
导入已经导出的消息(常用于端到端的历史消息牵移) ,导出参考MsgService#exportAllMessage(IMsgExportProcessor, boolean safeMode) 更多... | |
void | clearServerHistory (String sessionId, boolean deleteRoam) |
清空点对点历史消息 更多... | |
void | clearServerHistory (String sessionId, SessionTypeEnum sessionType) |
清空点对点历史消息,默认删除漫游消息 更多... | |
void | clearServerHistory (String sessionId, SessionTypeEnum sessionType, boolean deleteRoam) |
清空点对点历史消息 更多... | |
void | clearServerHistory (String sessionId, SessionTypeEnum sessionType, boolean sync, String ext) |
清空历史消息 更多... | |
void | deleteRangeHistory (String account, SessionTypeEnum sessionType, long startTime, long endTime) |
根据时间范围删除本地历史消息(startTime, entTime), 开区间,不包括两个端点,大于startTime, 小于endTime 更多... | |
InvocationFuture< RecentSessionList > | queryMySessionList (long minTimestamp, Long maxTimestamp, Integer needLastMsg, Integer limit, Integer hasMore) |
【会话服务】增量获取会话列表,增量+翻页 更多... | |
InvocationFuture< RecentSessionList > | queryMySessionList (QueryMySessionOption option) |
【会话服务】增量获取会话列表,增量+翻页 更多... | |
InvocationFuture< RecentSession > | queryMySession (@NonNull String sessionId) |
【会话服务】获取某一个会话 更多... | |
InvocationFuture< Void > | updateMySession (@NonNull String sessionId, @NonNull String ext) |
【会话服务】更新某一个会话,主要是设置会话的ext字段,如果会话不存在,则会创建出来,此时会话没有lastMsg 更多... | |
InvocationFuture< Void > | deleteMySession (@NonNull String[] sessionIdArr) |
【会话服务】删除会话 更多... | |
InvocationFuture< ThreadTalkHistory > | queryThreadTalkHistory (IMMessage anchor, long fromTime, long toTime, int limit, QueryDirectionEnum direction, boolean persist) |
查询thread聊天云端历史(支持p2p、群、超大群) 更多... | |
int | queryReplyCountInThreadTalkBlock (IMMessage msg) |
本地获取某thread消息的回复消息的条数,thread消息不被计入总数 更多... | |
InvocationFuture< Void > | addQuickComment (IMMessage msg, long replyType, String ext) |
增加一条快捷评论 更多... | |
InvocationFuture< Long > | addQuickComment (IMMessage msg, long replyType, String ext, boolean needPush, boolean needBadge, String pushTitle, String pushContent, Map< String, Object > pushPayload) |
增加一条快捷评论 更多... | |
InvocationFuture< Void > | removeQuickComment (IMMessage msg, long replyType, String ext) |
删除一条快捷评论 更多... | |
InvocationFuture< Long > | removeQuickComment (IMMessage msg, long replyType, String ext, boolean needPush, boolean needBadge, String pushTitle, String pushContent, Map< String, Object > pushPayload) |
删除一条快捷评论 更多... | |
InvocationFuture< List< QuickCommentOptionWrapper > > | queryQuickComment (List< IMMessage > msgList) |
获取快捷评论列表 更多... | |
InvocationFuture< CollectInfo > | addCollect (int type, String date, String ext, String uniqueId) |
添加一条收藏 更多... | |
InvocationFuture< Integer > | removeCollect (List< Pair< Long, Long >> collectInfo) |
批量移除收藏 更多... | |
InvocationFuture< CollectInfo > | updateCollect (CollectInfo info, String ext) |
更新一个收藏的扩展字段 更多... | |
InvocationFuture< CollectInfo > | updateCollect (long infoId, long createTime, String ext) |
更新一个收藏的扩展字段 更多... | |
InvocationFuture< CollectInfoPage > | queryCollect (int limit) |
从服务查询收藏列表 更多... | |
InvocationFuture< CollectInfoPage > | queryCollect (CollectInfo anchor, long toTime, int limit, QueryDirectionEnum direction) |
从服务端分页查询收藏列表 更多... | |
InvocationFuture< CollectInfoPage > | queryCollect (CollectInfo anchor, long toTime, int limit, QueryDirectionEnum direction, int type, boolean persist) |
从服务的分页查询收藏列表 更多... | |
InvocationFuture< Long > | addMsgPin (IMMessage msg, String ext) |
PIN一条消息 更多... | |
InvocationFuture< Long > | updateMsgPin (IMMessage msg, String ext) |
更新一条消息的PIN 更多... | |
InvocationFuture< Long > | removeMsgPin (IMMessage msg, String ext) |
移除一条消息的PIN 更多... | |
InvocationFuture< MsgPinSyncResponseOptionWrapper > | syncMsgPin (SessionTypeEnum sessionType, String sessionId, long timestamp) |
同步会话的PIN信息 更多... | |
List< MsgPinDbOption > | queryMsgPinBlock (String sessionId, SessionTypeEnum sessionType) |
本地获取会话的PIN消息列表 更多... | |
InvocationFuture< StickTopSessionInfo > | addStickTopSession (String sessionId, SessionTypeEnum sessionType, String ext) |
添加一个置顶会话 更多... | |
InvocationFuture< Void > | removeStickTopSession (String sessionId, SessionTypeEnum sessionType, String ext) |
删除一个置顶会话 更多... | |
InvocationFuture< StickTopSessionInfo > | updateStickTopSession (String sessionId, SessionTypeEnum sessionType, String ext) |
更新一个会话在置顶上的扩展字段 更多... | |
List< StickTopSessionInfo > | queryStickTopSessionBlock () |
获取置顶会话信息的列表 更多... | |
boolean | isStickTopSession (String sessionId, SessionTypeEnum sessionType) |
会话是否被置顶,若参数不合法,或者会话不存在,返回false 更多... | |
void | migrateMessages (String from, String to, boolean changeFrom) |
迁移消息聊天记录。将from账号的消息历史数据库合并到to账号的消息数据库中,同时迁移消息记录和最近联系人。 已存在的最近联系人不会更新。 更多... | |
Public 属性 | |
String | MSG_CHATTING_ACCOUNT_ALL = "all" |
目前没有与任何人对话,但能看到消息提醒(比如在消息列表界面),不需要在状态栏做消息通知 更多... | |
String | MSG_CHATTING_ACCOUNT_NONE = null |
目前没有与任何人对话,需要状态栏消息通知 更多... | |
云信消息服务接口
在文件 MsgService.java 第 58 行定义.
InvocationFuture<CollectInfo> com.netease.nimlib.sdk.msg.MsgService.addCollect | ( | int | type, |
String | date, | ||
String | ext, | ||
String | uniqueId | ||
) |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.addMsgPin | ( | IMMessage | msg, |
String | ext | ||
) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.addQuickComment | ( | IMMessage | msg, |
long | replyType, | ||
String | ext | ||
) |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.addQuickComment | ( | IMMessage | msg, |
long | replyType, | ||
String | ext, | ||
boolean | needPush, | ||
boolean | needBadge, | ||
String | pushTitle, | ||
String | pushContent, | ||
Map< String, Object > | pushPayload | ||
) |
增加一条快捷评论
msg | 回复对象 |
replyType | 回复类型 |
ext | 自定义扩展字段,最大8字符 |
needPush | 是否需要推送 |
needBadge | 是否需要角标 |
pushTitle | 推送标题 |
pushContent | 推送内容 |
pushPayload | 第三方自定义的推送属性,限制json类型 |
InvocationFuture<StickTopSessionInfo> com.netease.nimlib.sdk.msg.MsgService.addStickTopSession | ( | String | sessionId, |
SessionTypeEnum | sessionType, | ||
String | ext | ||
) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.cancelUploadAttachment | ( | IMMessage | imMessage | ) |
取消上传消息附件(图片、视频、文件类型的),如果附件已经上传成功,操作将会失败 。
如果成功取消了附件的上传,那么相应的消息会发送失败,对应的消息状态是MsgStatusEnum#fail,附件状态是AttachStatusEnum#cancel
注意:此操作暂时不支持聊天室
imMessage | 要取消上传附件的消息 |
LocalAntiSpamResult com.netease.nimlib.sdk.msg.MsgService.checkLocalAntiSpam | ( | String | content, |
String | replacement | ||
) |
检验本地反垃圾词库
content | 需要检查的文本 |
replacement | 反垃圾词库命中后替换文本 |
void com.netease.nimlib.sdk.msg.MsgService.clearAllUnreadCount | ( | ) |
将所有联系人的未读数清零(标记已读) 调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知
void com.netease.nimlib.sdk.msg.MsgService.clearChattingHistory | ( | String | account, |
SessionTypeEnum | sessionType | ||
) |
清除与指定用户的所有消息记录,且不在数据库记录此次操作
account | 会话ID |
sessionType | 聊天类型 |
void com.netease.nimlib.sdk.msg.MsgService.clearChattingHistory | ( | String | account, |
SessionTypeEnum | sessionType, | ||
boolean | ignore | ||
) |
清除与指定用户的所有本地消息记录
account | 会话ID |
sessionType | 聊天类型 |
ignore | true: 本地不记录清除操作; false: 本地记录清除操作,清除记录的作用参见MsgService#pullMessageHistory(IMMessage, int, boolean, boolean) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.clearMsgDatabase | ( | boolean | clearRecent | ) |
清空消息数据库的所有消息记录。
可选择是否要同时清空最近联系人列表数据库。
若最近联系人列表也被清空,会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知
clearRecent | 若为true,将同时清空最近联系人列表数据 |
void com.netease.nimlib.sdk.msg.MsgService.clearServerHistory | ( | String | sessionId, |
boolean | deleteRoam | ||
) |
清空点对点历史消息
sessionId | 用户帐号 |
deleteRoam | 是否删除漫游消息 |
void com.netease.nimlib.sdk.msg.MsgService.clearServerHistory | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
清空点对点历史消息,默认删除漫游消息
sessionId | 用户帐号 |
sessionType | 聊天类型 |
void com.netease.nimlib.sdk.msg.MsgService.clearServerHistory | ( | String | sessionId, |
SessionTypeEnum | sessionType, | ||
boolean | deleteRoam | ||
) |
清空点对点历史消息
sessionId | 用户帐号 |
sessionType | 聊天类型 |
deleteRoam | 是否删除漫游消息 |
void com.netease.nimlib.sdk.msg.MsgService.clearServerHistory | ( | String | sessionId, |
SessionTypeEnum | sessionType, | ||
boolean | sync, | ||
String | ext | ||
) |
清空历史消息
sessionId | 用户帐号 |
sessionType | 聊天类型 |
sync | 是否同步给其他端 |
ext | 扩展字段 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.clearUnreadCount | ( | String | account, |
SessionTypeEnum | sessionType | ||
) |
将指定最近联系人的未读数清零(标记已读)。
调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知
account | 聊天对象帐号 |
sessionType | 会话类型 |
InvocationFuture<List<SessionAckInfo> > com.netease.nimlib.sdk.msg.MsgService.clearUnreadCount | ( | List< Pair< String, SessionTypeEnum >> | sessionKeyList | ) |
将指定最近联系人的未读数清零(标记已读)。
调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知
sessionKeyList | 聊天对象帐号列表,Pair的第一项为会话ID,第二项为会话类型 会话类型支持传入SessionTypeEnum#P2P和SessionTypeEnum#Team |
InvocationFuture<List<SessionAckInfo> > com.netease.nimlib.sdk.msg.MsgService.clearUnreadCount | ( | SessionTypeEnum | sessionType | ) |
将指定会话类型的未读数清零(标记已读)。
调用该接口后,会触发MsgServiceObserve#observeRecentContact(Observer, boolean) 通知
sessionType | 会话类型,支持传入SessionTypeEnum#P2P和SessionTypeEnum#Team |
RecentContact com.netease.nimlib.sdk.msg.MsgService.createEmptyRecentContact | ( | String | contactId, |
SessionTypeEnum | sessionType, | ||
long | tag, | ||
long | time, | ||
boolean | saveToDB | ||
) |
创建一条空的联系人会话
contactId | 会话id ,对方帐号或群组id。 |
sessionType | 会话类型 |
tag | 会话tag , eg:置顶标签(UIKit中的实现: RECENT_TAG_STICKY) ,用户参照自己的tag 实现即可, 如不需要,传 0 即可。 |
time | 会话时间 ,单位为ms。 |
saveToDB | 是否需要将会话保存在DB中,注意以下两点: 1,如果已经存在相同的会话(contactId 、sessionType 一样),则不会保存在db中; 2,如果之前不存在相同的会话,且needSaveToDB为true 会触发MsgServiceObserve#observeRecentContact(Observer, boolean)通知; |
RecentContact com.netease.nimlib.sdk.msg.MsgService.createEmptyRecentContact | ( | String | contactId, |
SessionTypeEnum | sessionType, | ||
long | tag, | ||
long | time, | ||
boolean | saveToDB, | ||
boolean | withLastMsg | ||
) |
创建一条空的联系人会话
contactId | 会话id ,对方帐号或群组id。 |
sessionType | 会话类型 |
tag | 会话tag , eg:置顶标签(UIKit中的实现: RECENT_TAG_STICKY) ,用户参照自己的tag 实现即可, 如不需要,传 0 即可。 |
time | 会话时间 ,单位为ms。 |
saveToDB | 是否需要将会话保存在DB中,注意以下两点: 1,如果已经存在相同的会话(contactId 、sessionType 一样),则不会保存在db中; 2,如果之前不存在相同的会话,且needSaveToDB为true 会触发MsgServiceObserve#observeRecentContact(Observer, boolean)通知; |
withLastMsg | 是否放入最后一条消息的相关信息 |
void com.netease.nimlib.sdk.msg.MsgService.deleteChattingHistory | ( | IMMessage | message | ) |
删除一条消息记录,并在数据库记录此操作 从云端拉取消息时,如果本地有删除该消息的操作记录,则该消息不会入库 删除标记会被清除标记覆盖
message | 待删除的消息记录 |
void com.netease.nimlib.sdk.msg.MsgService.deleteChattingHistory | ( | IMMessage | message, |
boolean | ignore | ||
) |
删除一条消息记录
message | 待删除的消息记录 |
ignore | true: 本地不记录清除操作; false: 本地记录清除操作 从云端拉取消息时,如果本地有删除该消息的操作记录,则该消息不会入库 删除标记会被清除标记覆盖 |
void com.netease.nimlib.sdk.msg.MsgService.deleteChattingHistory | ( | List< IMMessage > | msgList, |
boolean | ignore | ||
) |
删除多条消息记录
msgList | 待删除的消息记录 |
ignore | true: 本地不记录清除操作; false: 本地记录清除操作 从云端拉取消息时,如果本地有删除该消息的操作记录,则该消息不会入库 删除标记会被清除标记覆盖 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.deleteMsgSelf | ( | IMMessage | msg, |
String | ext | ||
) |
单向删除一条消息
msg | 被单向删除的消息 |
ext | 扩展字段 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.deleteMsgSelf | ( | List< IMMessage > | msgList, |
String | ext | ||
) |
单向删除多条消息
msgList | 被单向删除的消息 |
ext | 扩展字段 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.deleteMySession | ( | @NonNull String [] | sessionIdArr | ) |
【会话服务】删除会话
sessionIdArr | 每一项的格式:分为p2p/team/superTeam,格式分别是:p2p|accid、team|tid、super_team|tid |
void com.netease.nimlib.sdk.msg.MsgService.deleteRangeHistory | ( | String | account, |
SessionTypeEnum | sessionType, | ||
long | startTime, | ||
long | endTime | ||
) |
根据时间范围删除本地历史消息(startTime, entTime), 开区间,不包括两个端点,大于startTime, 小于endTime
account | 删除账号 |
sessionType | 删除会话类型 |
startTime | 开始时间 |
endTime | 结束时间 |
void com.netease.nimlib.sdk.msg.MsgService.deleteRecentContact | ( | RecentContact | recent | ) |
从最近联系人会话列表中删除一项,既删本地也删漫游。
调用这个接口删除数据后,不会引发观察者通知。
recent | 待删除的最近联系人会话项 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.deleteRecentContact | ( | String | account, |
SessionTypeEnum | sessionType, | ||
DeleteTypeEnum | deleteType, | ||
boolean | sendAck | ||
) |
删除最近联系人记录。
调用该接口后,不会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知
account | 会话ID |
sessionType | 会话类型,只能选SessionTypeEnum#P2P和SessionTypeEnum#Team会删漫游消息 |
deleteType | 删除类型,决定是否删除本地记录和漫游记录, 如果为null,视为DeleteTypeEnum#REMAIN |
sendAck | 如果参数合法,是否向本账号的其他端标记清除未读数 |
void com.netease.nimlib.sdk.msg.MsgService.deleteRecentContact2 | ( | String | account, |
SessionTypeEnum | sessionType | ||
) |
删除最近联系人记录,既删本地也删漫游。
调用该接口后,会触发MsgServiceObserve#observeRecentContactDeleted(Observer, boolean)通知
account | |
sessionType |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.deleteRoamingRecentContact | ( | String | contactId, |
SessionTypeEnum | sessionTypeEnum | ||
) |
删除指定最近联系人的漫游消息。 不删除本地消息,但如果在其他端登录,当前时间点该会话已经产生的消息不漫游。
contactId | 最近联系人的ID(好友帐号,群ID等) |
sessionTypeEnum | 会话类型 |
void com.netease.nimlib.sdk.msg.MsgService.deleteRoamMsgHasMoreTag | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
删除是否有更多漫游的标记
sessionId | 会话ID |
sessionType | 会话类型 |
AbortableFuture<Void> com.netease.nimlib.sdk.msg.MsgService.downloadAttachment | ( | IMMessage | msg, |
boolean | thumb | ||
) |
正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载
msg | 附件所在的消息体 |
thumb | 下载缩略图还是原文件。为true时,仅下载缩略图。 该参数仅对图片和视频类消息有效 |
boolean com.netease.nimlib.sdk.msg.MsgService.everBeenDeleted | ( | IMMessage | message | ) |
消息是否曾被从本地删除
message | 待查询消息 |
AbortableFuture<Void> com.netease.nimlib.sdk.msg.MsgService.exportAllMessage | ( | IMsgExportProcessor | exportProcessor, |
boolean | safeMode | ||
) |
导出本地db 的所有消息并上传给服务器,对应于导入消息的操作(常用于端到端的历史消息牵移),如果有云端消息记录,不建议使用这个接口
导入参考MsgService#importAllMessage(IMsgImportProcessor, boolean safeMode)
只会导出以下类型的消息:文本消息 、图片消息、 音频消息、 视频消息 、文件消息、自定义消息
整个过程如下:
step1 : 消息转换成文件
step2 : 压缩文件(用户自定义过程)
step3 : 加密文件(用户自定义过程)
step4 : 上传文件
错误码:
DB中没有数据 : MigrationConstant#EXPORT_ERR_DB_EMPTY
本地消息格式化失败 : MigrationConstant#EXPORT_ERR_LOCAL_FORMAT
文件压缩失败(用户自定义过程) : MigrationConstant#EXPORT_ERR_USER_CUSTOM_ZIP
消息导出时,文件加密失败(用户自定义过程) : MigrationConstant#EXPORT_ERR_USER_CUSTOM_ENCRYPT
上传文件失败 : MigrationConstant#EXPORT_ERR_UPLOAD_FILE
消息导出时,本地有消息,但是都被过滤了 : MigrationConstant#EXPORT_ERR_EMPTY_AFTER_FILTER
exportProcessor | 消息导出处理器,必须设置 |
safeMode | 是否为安全模式,安全模式下处理完成之后会删除相关的文件(包括用户自定义过程的) |
InvocationFuture<GetMessagesDynamicallyResult> com.netease.nimlib.sdk.msg.MsgService.getMessagesDynamically | ( | GetMessagesDynamicallyParam | param | ) |
int com.netease.nimlib.sdk.msg.MsgService.getTotalUnreadCount | ( | ) |
获取未读数总数
int com.netease.nimlib.sdk.msg.MsgService.getTotalUnreadCount | ( | boolean | notify | ) |
获取未读数总数
notify | true表示只查询排除免打扰之外的消息总未读数,false表示只查询免打扰的消息总未读数 |
int com.netease.nimlib.sdk.msg.MsgService.getUnreadCountBySessionType | ( | SessionTypeEnum | sessionType | ) |
获取指定会话类型的总未读数
AbortableFuture<Void> com.netease.nimlib.sdk.msg.MsgService.importAllMessage | ( | IMsgImportProcessor | iMsgImportProcessor, |
boolean | safeMode | ||
) |
导入已经导出的消息(常用于端到端的历史消息牵移) ,导出参考MsgService#exportAllMessage(IMsgExportProcessor, boolean safeMode)
iMsgImportProcessor | 消息导入处理器,必须设置 |
safeMode | 是否为安全模式,安全模式下处理完成之后会删除相关的文件(包括用户自定义过程的) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.importRecentSessions | ( | List< Pair< String, SessionTypeEnum >> | sessions | ) |
导入最近会话,批量导入,仅支持 contactId 和 sessionType 两个字段
sessions |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.insertLocalMessage | ( | IMMessage | msg, |
String | fromAccount | ||
) |
插入消息到本地数据库,且通知更新UI界面,但不发送到服务器端。发送一条可设置他人为发送方的本地消息给自己。
该接口将消息保存到数据库后,会通知到UI,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。
msg | 待保存的消息对象 |
fromAccount | 发送者ID |
boolean com.netease.nimlib.sdk.msg.MsgService.isStickTopSession | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
会话是否被置顶,若参数不合法,或者会话不存在,返回false
sessionId | 会话ID,如果为""或null,返回false |
sessionType | 会话类型,如果为null,返回false |
void com.netease.nimlib.sdk.msg.MsgService.migrateMessages | ( | String | from, |
String | to, | ||
boolean | changeFrom | ||
) |
迁移消息聊天记录。将from账号的消息历史数据库合并到to账号的消息数据库中,同时迁移消息记录和最近联系人。
已存在的最近联系人不会更新。
from | 源聊天记录账号 |
to | 目标聊天记录账号 |
changeFrom | 是否要修改源聊天记录中 IMMessage 的 fromAccount,如果为true,fromAccount由from改为to |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullHistoryById | ( | List< MessageKey > | msgKeyList, |
boolean | persist | ||
) |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistory | ( | IMMessage | anchor, |
int | limit, | ||
boolean | persist | ||
) |
从服务器拉取消息历史记录。该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。
当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 查询锚点。 首次查询,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
limit | 本次查询的消息条数上限(最多100条) |
persist | 通过该接口获取的漫游消息记录,是否保存到本地消息数据库。 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistory | ( | IMMessage | anchor, |
int | limit, | ||
boolean | persist, | ||
boolean | persistClear | ||
) |
从服务器拉取消息历史记录。该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。
当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 查询锚点。 首次查询,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
limit | 本次查询的消息条数上限(最多100条) |
persist | 通过该接口获取的漫游消息记录,是否保存到本地消息数据库。 |
persistClear | 是否保存清除记录之前的消息到本地数据库,在persist==true时生效 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistory | ( | MsgFullKeywordSearchConfig | config | ) |
云端历史消息全文检索
config | 配置 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryEx | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
boolean | persist | ||
) |
从服务器拉取消息历史记录。以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
persist | 通过该接口获取的漫游消息记录,是否保存到本地消息数据库。 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryExType | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
MsgTypeEnum [] | msgTypes | ||
) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。
以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小,默认不保存到数据库
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
msgTypes | 消息类型,数组。消息类型仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,100:自定义,其它为非法参数 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryExType | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
MsgTypeEnum [] | msgTypes, | ||
boolean | persist | ||
) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果是否保存到本地消息数据库。
以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
msgTypes | 消息类型,数组。消息类型仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,100:自定义,其它为非法参数 |
persist | 通过该接口获取的漫游消息记录,是否保存到本地消息数据库。 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryExType | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
MsgTypeEnum [] | msgTypes, | ||
boolean | persist, | ||
boolean | persistClear | ||
) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。
以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
msgTypes | 消息类型,数组。消息类型仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,100:自定义,其它为非法参数 |
persist | 通过该接口获取的漫游消息记录,要不要保存到本地消息数据库。 |
persistClear | 是否保存被清除的消息到本地数据库,在persist==true时生效 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryExType | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
MsgTypeEnum [] | msgTypes, | ||
boolean | persist, | ||
boolean | persistClear, | ||
IMMessageFilter | customFilter | ||
) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。
以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
msgTypes | 消息类型,数组。消息类型仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,100:自定义,其它为非法参数 |
persist | 通过该接口获取的漫游消息记录,要不要保存到本地消息数据库。 |
persistClear | 是否保存被清除的消息到本地数据库,在persist==true时生效 |
customFilter | 过滤器回调,如果返回true则被忽略,即视为没有拉到这条消息 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryExType | ( | IMMessage | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
MsgTypeEnum [] | msgTypes, | ||
boolean | persist, | ||
boolean | persistClear, | ||
IMMessageFilter | customFilter, | ||
boolean | updateUnread | ||
) |
从服务器拉取消息历史记录,可以指定查询的消息类型,结果不存本地消息数据库。
以锚点anchor作为起始点(不包含锚点),根据direction参数,往前或往后查询由锚点到toTime之间的最多limit条消息。
查询范围由toTime和limit共同决定,以先到为准。如果到toTime之间消息大于limit条,返回limit条记录,如果小于limit条,返回实际条数。 当已经查询到头时,返回的结果列表的size可能会比limit小
anchor | 起始时间点的消息,不能为null。 设置自定义锚点时,使用 MessageBuilder#createEmptyMessage(String, SessionTypeEnum, long) 创建一个空对象即可 |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向,QUERY_OLD按结束时间点逆序查询,逆序排列;QUERY_NEW按起始时间点正序起查,正序排列 |
msgTypes | 消息类型,数组。消息类型仅支持 0:文本,1:图片,2:语音,3:视频,4:地理位置,5:通知,6:文件,10:提示,100:自定义,其它为非法参数 |
persist | 通过该接口获取的漫游消息记录,要不要保存到本地消息数据库。 |
persistClear | 是否保存被清除的消息到本地数据库,在persist==true时生效 |
customFilter | 过滤器回调,如果返回true则被忽略,即视为没有拉到这条消息 |
updateUnread | 是否计算未读数 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.pullMessageHistoryOrderByTime | ( | MsgTimingFullKeywordSearchConfig | config | ) |
云端历史消息全文检索(按时间排序,不按会话分组)
config | 检索配置 |
InvocationFuture<CollectInfoPage> com.netease.nimlib.sdk.msg.MsgService.queryCollect | ( | int | limit | ) |
InvocationFuture<CollectInfoPage> com.netease.nimlib.sdk.msg.MsgService.queryCollect | ( | CollectInfo | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction | ||
) |
从服务端分页查询收藏列表
anchor | 结束查询的最后一条收藏(不包含在查询结果中) |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向 |
InvocationFuture<CollectInfoPage> com.netease.nimlib.sdk.msg.MsgService.queryCollect | ( | CollectInfo | anchor, |
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
int | type, | ||
boolean | persist | ||
) |
从服务的分页查询收藏列表
anchor | 结束查询的最后一条收藏(不包含在查询结果中) |
toTime | 结束时间点单位毫秒 |
limit | 本次查询的消息条数上限(最多100条) |
direction | 查询方向 |
type | 收藏类型 |
persist | 是否持久化 |
IMMessage com.netease.nimlib.sdk.msg.MsgService.queryLastMessage | ( | String | account, |
SessionTypeEnum | sessionType | ||
) |
查询同指定用户的最近一条消息
account | 账号 |
sessionType | 会话类型 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageList | ( | String | account, |
SessionTypeEnum | sessionType, | ||
long | offset, | ||
int | limit | ||
) |
从本地消息数据库中查询消息历史。
按照消息记录时间先后倒序查询,查询条件为 "ORDER BY time desc limit ${limit} offset ${offset}"。
注意:返回结果的消息历史列表排列顺序也为倒序:即时间大的消息在前,时间小的消息在后。
account | 待查询的聊天对象帐号(个人帐号/群组ID) |
sessionType | 聊天对象类型(单人聊天/群组) |
offset | 查询偏移量 |
limit | 查询列表限长 |
List<IMMessage> com.netease.nimlib.sdk.msg.MsgService.queryMessageListByServerIdBlock | ( | List< String > | serverIds | ) |
通过 Server ID 批量获取IMMessage(同步版本) 注意:一个ServerId可能对应多条消息
serverIds | 消息的Server ID列表 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListBySubtype | ( | MsgTypeEnum | msgTypeEnum, |
IMMessage | anchor, | ||
int | limit, | ||
int | subtype | ||
) |
List<IMMessage> com.netease.nimlib.sdk.msg.MsgService.queryMessageListBySubtypeBlock | ( | MsgTypeEnum | msgTypeEnum, |
IMMessage | anchor, | ||
int | limit, | ||
int | subtype | ||
) |
通过消息子类型查询本地消息记录(同步版本)
msgTypeEnum | 消息类型 |
anchor | 搜索的消息锚点 |
limit | 搜索结果的条数限制 |
subtype | 子类型 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListByType | ( | MsgTypeEnum | msgTypeEnum, |
IMMessage | anchor, | ||
int | limit | ||
) |
通过消息类型从本地消息数据库中查询消息历史。查询范围由msgTypeEnum参数和anchor的sessionId决定 该接口查询方向为从后往前。以锚点anchor作为起始点(不包含锚点),往前查询最多limit条消息。
msgTypeEnum | 消息类型 |
anchor | 搜索的消息锚点 |
limit | 搜索结果的条数限制 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListByType | ( | MsgTypeEnum | msgTypeEnum, |
Long | maxTime, | ||
int | limit | ||
) |
通过消息类型查询所有消息记录,
maxTime | 查询开始时间, 开区间, 往后或者limit条, 如果maxTime为空表示查询所有记录 |
msgTypeEnum | 消息类型 |
limit | 每次获取条数, limit<=0 返回参数错误 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListByTypes | ( | List< MsgTypeEnum > | types, |
IMMessage | anchor, | ||
long | toTime, | ||
QueryDirectionEnum | direction, | ||
int | limit, | ||
boolean | asc | ||
) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询指定消息类型的消息历史。
根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。
查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。
查询结果排序规则:如果asc为true,结果按照时间升序排列,如果为false,按照时间降序排列
注意:查询结果不包含锚点。
types | 查询的消息类型集合, 传入null表示所有消息类型,同 MsgService#queryMessageListExTime 结果 |
anchor | 查询锚点 |
toTime | 查询截止时间,若方向为 QUERY_OLD,toTime 应小于 anchor.getTime()。方向为 QUERY_NEW,toTime 应大于 anchor.getTime(), 填0表示没有时间限制,以 limit限制为主 |
direction | 查询方向 |
limit | 查询结果的条数限制 |
asc | 查询结果的排序规则,如果为true,结果按照时间升序排列,如果为false,按照时间降序排列 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListByTypesV2 | ( | List< MsgTypeEnum > | types, |
IMMessage | anchor, | ||
long | toTime, | ||
QueryDirectionEnum | direction, | ||
int | limit, | ||
boolean | asc | ||
) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询指定消息类型的消息历史。
根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。
查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。
查询结果排序规则:如果asc为true,结果按照时间升序排列,如果为false,按照时间降序排列
注意:查询结果不包含锚点。
types | 查询的消息类型集合, 传入null表示所有消息类型,同 MsgService#queryMessageListExTime 结果 |
anchor | 查询锚点,锚点消息类型可不在查询的消息类型集合范围内 |
toTime | 查询截止时间,若方向为 QUERY_OLD,toTime 应小于 anchor.getTime()。方向为 QUERY_NEW,toTime 应大于 anchor.getTime(), 填0表示没有时间限制,以 limit限制为主 |
direction | 查询方向 |
limit | 查询结果的条数限制 |
asc | 查询结果的排序规则,如果为true,结果按照时间升序排列,如果为false,按照时间降序排列 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListByUuid | ( | List< String > | uuids | ) |
通过uuid批量获取IMMessage
uuids | 消息的uuid列表 |
List<IMMessage> com.netease.nimlib.sdk.msg.MsgService.queryMessageListByUuidBlock | ( | List< String > | uuids | ) |
通过uuid批量获取IMMessage(同步版本)
uuids | 消息的uuid列表 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListEx | ( | IMMessage | anchor, |
QueryDirectionEnum | direction, | ||
int | limit, | ||
boolean | asc | ||
) |
根据锚点和方向从本地消息数据库中查询消息历史。
根据提供的方向(direct),查询比anchor更老(QUERY_OLD)或更新(QUERY_NEW)的最靠近anchor的limit条数据。
调用者可使用asc参数指定结果排序规则,结果使用time作为排序字段。
注意:查询结果不包含锚点。
anchor | 查询锚点 |
direction | 查询方向 |
limit | 查询结果的条数限制 |
asc | 查询结果的排序规则,如果为true,结果按照时间升序排列,如果为false,按照时间降序排列 |
List<IMMessage> com.netease.nimlib.sdk.msg.MsgService.queryMessageListExBlock | ( | IMMessage | anchor, |
QueryDirectionEnum | direction, | ||
int | limit, | ||
boolean | asc | ||
) |
根据锚点和方向从本地消息数据库中查询消息历史。(同步函数)
根据提供的方向(direct),查询比anchor更老(QUERY_OLD)或更新(QUERY_NEW)的最靠近anchor的limit条数据。
调用者可使用asc参数指定结果排序规则,结果使用time作为排序字段。
注意:查询结果不包含锚点。
anchor | 查询锚点 |
direction | 查询方向 |
limit | 查询结果的条数限制 |
asc | 查询结果的排序规则,如果为true,结果按照时间升序排列,如果为false,按照时间降序排列 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryMessageListExTime | ( | IMMessage | anchor, |
long | toTime, | ||
QueryDirectionEnum | direction, | ||
int | limit | ||
) |
根据起始、截止时间点以及查询方向从本地消息数据库中查询消息历史。
根据提供的方向 (direction),以 anchor 为起始点,往前或往后查询由 anchor 到 toTime 之间靠近 anchor 的 limit 条消息。
查询范围由 toTime 和 limit 共同决定,以先到为准。如果到 toTime 之间消息大于 limit 条,返回 limit 条记录,如果小于 limit 条,返回实际条数。
查询结果排序规则:direction 为 QUERY_OLD 时 按时间降序排列,direction 为 QUERY_NEW 时按照时间升序排列。
注意:查询结果不包含锚点。
anchor | 查询锚点 |
toTime | 查询截止时间,若方向为 QUERY_OLD,toTime 应小于 anchor.getTime()。方向为 QUERY_NEW,toTime 应大于 anchor.getTime() |
direction | 查询方向 |
limit | 查询结果的条数限制 |
List<MsgPinDbOption> com.netease.nimlib.sdk.msg.MsgService.queryMsgPinBlock | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
本地获取会话的PIN消息列表
sessionId | 会话ID |
sessionType | 会话类型 |
InvocationFuture<RecentSession> com.netease.nimlib.sdk.msg.MsgService.queryMySession | ( | @NonNull String | sessionId | ) |
【会话服务】获取某一个会话
sessionId | 分为p2p/team/superTeam,格式分别是:p2p|accid、team|tid、super_team|tid |
InvocationFuture<RecentSessionList> com.netease.nimlib.sdk.msg.MsgService.queryMySessionList | ( | long | minTimestamp, |
Long | maxTimestamp, | ||
Integer | needLastMsg, | ||
Integer | limit, | ||
Integer | hasMore | ||
) |
【会话服务】增量获取会话列表,增量+翻页
minTimestamp | 最小时间戳,作为请求参数时表示增量获取Session列表,传0表示全量获取 |
maxTimestamp | 最大时间戳,翻页时使用 |
needLastMsg | 是否需要lastMsg,0或者1,默认1 |
limit | 结果集limit,最大100,默认100 |
hasMore | 没用 |
InvocationFuture<RecentSessionList> com.netease.nimlib.sdk.msg.MsgService.queryMySessionList | ( | QueryMySessionOption | option | ) |
InvocationFuture<List<QuickCommentOptionWrapper> > com.netease.nimlib.sdk.msg.MsgService.queryQuickComment | ( | List< IMMessage > | msgList | ) |
RecentContact com.netease.nimlib.sdk.msg.MsgService.queryRecentContact | ( | String | contactId, |
SessionTypeEnum | sessionType | ||
) |
根据 contactId 与 sessionType 从db 中查询联系人会话记录。
contactId | 会话id ,对方帐号或群组id。 |
sessionType | 会话类型。 |
InvocationFuture<List<RecentContact> > com.netease.nimlib.sdk.msg.MsgService.queryRecentContacts | ( | ) |
查询最近联系人会话列表数据
InvocationFuture<List<RecentContact> > com.netease.nimlib.sdk.msg.MsgService.queryRecentContacts | ( | int | limit | ) |
InvocationFuture<List<RecentContact> > com.netease.nimlib.sdk.msg.MsgService.queryRecentContacts | ( | RecentContact | anchor, |
QueryDirectionEnum | direction, | ||
int | limit | ||
) |
查询最近联系人会话列表数据,可按时间逆序或者正序查询指定数量的最新会话列表数据
anchor | 查询最近联系人会话列表的锚点 如果首次查询传null即可; 如果首次查询,当查询方向direction为QUERY_NEW时,则时间按0开始查询; 如果首次查询,当查询方向direction为QUERY_OLD时,则时间按当前系统时间开始查询; 如果想查询下一页数据,传入上一页数据的最后一个RecentContact即可 |
direction | 查询方向 QUERY_OLD查询在时间在anchor之前的数据,逆序排列; QUERY_NEW查询时间在anchor之后的数据,正序排列 |
limit | 获取本地会话的数量 最大100,超过100修正到100 |
InvocationFuture<List<RecentContact> > com.netease.nimlib.sdk.msg.MsgService.queryRecentContacts | ( | MsgTypeEnum | filterMsgType | ) |
查询联系人最近会话列表数据, 最近一条不等于过滤消息类型, eg: 需要过滤MsgTypeEnum.notification, 则传入改type note :该方法返回未读为全量消息未读
filterMsgType | 过滤消息类型 |
InvocationFuture<List<RecentContact> > com.netease.nimlib.sdk.msg.MsgService.queryRecentContacts | ( | Set< MsgTypeEnum > | filterMsgTypeSet | ) |
查询联系人最近会话列表数据, 最近一条不在过滤消息类型中, eg: 需要过滤MsgTypeEnum.notification, 则传入改type note :该方法返回未读为全量消息未读
filterMsgTypeSet | 过滤消息类型 |
List<RecentContact> com.netease.nimlib.sdk.msg.MsgService.queryRecentContactsBlock | ( | ) |
查询最近联系人会话列表数据(同步版本)
List<RecentContact> com.netease.nimlib.sdk.msg.MsgService.queryRecentContactsBlock | ( | int | limit | ) |
查询最近联系人会话列表数据(同步版本),可以设置limit, 防止本地会话过多时,导致第一次加载慢
limit | 获取本地会话的数量,最大100,超过100修正到100 |
List<RecentContact> com.netease.nimlib.sdk.msg.MsgService.queryRecentContactsBlock | ( | RecentContact | anchor, |
QueryDirectionEnum | direction, | ||
int | limit | ||
) |
查询最近联系人会话列表数据(同步版本),可按时间逆序或者正序查询指定数量的最新会话列表数据
anchor | 查询最近联系人会话列表的锚点 如果首次查询传null即可; 如果首次查询,当查询方向direction为QUERY_NEW时,则时间按0开始查询; 如果首次查询,当查询方向direction为QUERY_OLD时,则时间按当前系统时间开始查询; 如果想查询下一页数据,传入上一页数据的最后一个RecentContact即可 |
direction | 查询方向 QUERY_OLD查询在时间在queryTime之前的数据,逆序排列; QUERY_NEW查询时间在queryTime之后的数据,正序排列 |
limit | 获取本地会话的数量 最大100,超过100修正到100 |
List<RecentContact> com.netease.nimlib.sdk.msg.MsgService.queryRecentContactsBlock | ( | MsgTypeEnum | filterMsgType | ) |
查询联系人最近会话列表数据(同步版本), 最近一条不等于过滤消息类型, 该方法可能会执行较长时间,建议使用异步版本, note :该方法返回未读为全量消息未读
filterMsgType | 过滤消息类型 |
List<RecentContact> com.netease.nimlib.sdk.msg.MsgService.queryRecentContactsBlock | ( | Set< MsgTypeEnum > | filterMsgTypeSet | ) |
查询联系人最近会话列表数据(同步版本), 最近一条不在过滤消息类型中, 该方法可能会执行较长时间,建议使用异步版本, note :该方法返回未读为全量消息未读
filterMsgTypeSet | 过滤消息类型 |
int com.netease.nimlib.sdk.msg.MsgService.queryReplyCountInThreadTalkBlock | ( | IMMessage | msg | ) |
本地获取某thread消息的回复消息的条数,thread消息不被计入总数
msg | thread中的某一条消息 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.queryRoamMsgHasMoreTagServerId | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
获取是否有更多漫游消息标记的serverid,如果没有,回调0L
sessionId | 会话ID |
sessionType | 会话类型 |
long com.netease.nimlib.sdk.msg.MsgService.queryRoamMsgHasMoreTagServerIdBlock | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
获取是否有更多漫游消息标记的serverid,如果没有,回调0L(同步接口)
sessionId | 会话ID |
sessionType | 会话类型 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.queryRoamMsgHasMoreTime | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
获取是否有更多漫游消息标记的时间戳,如果没有,回调0L
sessionId | 会话ID |
sessionType | 会话类型 |
long com.netease.nimlib.sdk.msg.MsgService.queryRoamMsgHasMoreTimeBlock | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
获取是否有更多漫游消息标记的时间戳,如果没有,回调0L(同步接口)
sessionId | 会话ID |
sessionType | 会话类型 |
List<StickTopSessionInfo> com.netease.nimlib.sdk.msg.MsgService.queryStickTopSessionBlock | ( | ) |
获取置顶会话信息的列表
InvocationFuture<ThreadTalkHistory> com.netease.nimlib.sdk.msg.MsgService.queryThreadTalkHistory | ( | IMMessage | anchor, |
long | fromTime, | ||
long | toTime, | ||
int | limit, | ||
QueryDirectionEnum | direction, | ||
boolean | persist | ||
) |
查询thread聊天云端历史(支持p2p、群、超大群)
anchor | 查找锚点,查找对象为此消息所在的thread中的消息 |
fromTime | 起始时间 |
toTime | 终止时间 |
limit | 条数限制 |
direction | 方向 |
persist | 是否持久化 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.queryUnreadMessageList | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
根据会话ID和会话类型查找未读消息列表
sessionId | 会话ID |
sessionType | 会话类型 |
List<IMMessage> com.netease.nimlib.sdk.msg.MsgService.queryUnreadMessageListBlock | ( | String | sessionId, |
SessionTypeEnum | sessionType | ||
) |
根据会话ID和会话类型查找未读消息列表(同步版本)
sessionId | 会话ID |
sessionType | 会话类型 |
void com.netease.nimlib.sdk.msg.MsgService.registerCustomAttachmentParser | ( | MsgAttachmentParser | customParser | ) |
如果第三方app需要自定义的附件消息类型,再次注册自己的附件解析器。
客户自定义的消息类型为com.netease.nimlib.sdk.msg.constant.MsgTypeEnum#custom
自定义附件类型须继承自MsgAttachment。
customParser | 附件解析器 |
void com.netease.nimlib.sdk.msg.MsgService.registerIMMessageFilter | ( | IMMessageFilter | filter | ) |
注册通知消息过滤器
filter | 上层实现的通知消息过滤器,决定是否过滤通知消息(不存储到数据库中),传 null 表示注销(取消)通知消息过滤器 |
void com.netease.nimlib.sdk.msg.MsgService.registerShouldShowNotificationWhenRevokeFilter | ( | ShowNotificationWhenRevokeFilter | filter | ) |
注册是否在撤回消息时展示通知的过滤器
InvocationFuture<Integer> com.netease.nimlib.sdk.msg.MsgService.removeCollect | ( | List< Pair< Long, Long >> | collectInfo | ) |
批量移除收藏
collectInfo | 要移除的收藏的关键信息组成的列表,每一项为一个Pair,其中第一项为收藏的ID,第二项为收藏的创建时间 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.removeMsgPin | ( | IMMessage | msg, |
String | ext | ||
) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.removeQuickComment | ( | IMMessage | msg, |
long | replyType, | ||
String | ext | ||
) |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.removeQuickComment | ( | IMMessage | msg, |
long | replyType, | ||
String | ext, | ||
boolean | needPush, | ||
boolean | needBadge, | ||
String | pushTitle, | ||
String | pushContent, | ||
Map< String, Object > | pushPayload | ||
) |
删除一条快捷评论
msg | 回复对象 |
replyType | 回复类型 |
ext | 自定义扩展字段,最大8字符 |
needPush | 是否需要推送 |
needBadge | 是否需要角标 |
pushTitle | 推送标题 |
pushContent | 推送内容 |
pushPayload | 第三方自定义的推送属性,限制json类型 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.removeStickTopSession | ( | String | sessionId, |
SessionTypeEnum | sessionType, | ||
String | ext | ||
) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.replyMessage | ( | IMMessage | msg, |
IMMessage | replyMsg, | ||
boolean | resend | ||
) |
回复消息。
如果需要更新发送进度,请调用MsgServiceObserve#observeMsgStatus(com.netease.nimlib.sdk.Observer, boolean)
msg | 带发送的消息体,由MessageBuilder构造 |
replyMsg | 被回复的消息 |
resend | 如果是发送失败后重发,标记为true,否则填false |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.revokeMessage | ( | IMMessage | message | ) |
消息撤回 ,默认没有第三方推送(包括IOS平台的推送),参考MsgService#revokeMessageEx(IMMessage, String, Map)
message | 待撤回的消息 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.revokeMessage | ( | IMMessage | message, |
String | customApnsText, | ||
Map< String, Object > | pushPayload, | ||
boolean | shouldNotifyBeCount | ||
) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on)
message | 待撤回的消息 |
customApnsText | 第三方透传消息推送文本,不填则不推送 |
pushPayload | 第三方自定义的推送属性,限制json类型,长度2048 |
shouldNotifyBeCount | 撤回通知是否更新未读数 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.revokeMessage | ( | IMMessage | message, |
String | customApnsText, | ||
Map< String, Object > | pushPayload, | ||
boolean | shouldNotifyBeCount, | ||
String | postscript | ||
) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on)
message | 待撤回的消息 |
customApnsText | 第三方透传消息推送文本,不填则不推送 |
pushPayload | 第三方自定义的推送属性,限制json类型,长度2048 |
shouldNotifyBeCount | 撤回通知是否更新未读数 |
postscript | 附言 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.revokeMessage | ( | IMMessage | message, |
String | customApnsText, | ||
Map< String, Object > | pushPayload, | ||
boolean | shouldNotifyBeCount, | ||
String | postscript, | ||
String | attach | ||
) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送)与未读数变化,如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on)
message | 待撤回的消息 |
customApnsText | 第三方透传消息推送文本,不填则不推送 |
pushPayload | 第三方自定义的推送属性,限制json类型,长度2048 |
shouldNotifyBeCount | 撤回通知是否更新未读数 |
postscript | 附言 |
attach | 扩展字段 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.revokeMessageEx | ( | IMMessage | message, |
String | customApnsText, | ||
Map< String, Object > | pushPayload | ||
) |
消息撤回 , 并设置相应的第三方推送配置(包括IOS平台的推送),如果想要关闭App内的返回消息提醒,参考NIMClient#toggleRevokeMessageNotification(boolean on)
message | 待撤回的消息 |
customApnsText | 第三方透传消息推送文本,不填则不推送 |
pushPayload | 第三方自定义的推送属性,限制json类型,长度2048 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.saveMessageToLocal | ( | IMMessage | msg, |
boolean | notify | ||
) |
保存消息到本地数据库,但不发送到服务器端。用于第三方APP保存本地提醒一类的消息。
该接口将消息保存到数据库后,如果需要通知到UI,可将notify设置为true,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。
msg | 待保存的消息对象 |
notify | 是否要通知UI更新界面 |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.saveMessageToLocalEx | ( | IMMessage | msg, |
boolean | notify, | ||
long | time | ||
) |
保存消息到本地数据库,但不发送到服务器端。可设置保存消息的时间 用于第三方APP保存本地提醒一类的消息。 该接口将消息保存到数据库后,如果需要通知到UI,可将notify设置为true,此时会触发MsgServiceObserve#observeReceiveMessage(Observer, boolean)通知。
msg | 待保存的消息对象 |
notify | 是否要通知UI更新界面 |
time | 保存消息的时间, 使用IMMessage#getTime() |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchAllMessage | ( | MsgSearchOption | option | ) |
从本地消息数据库全局搜索消息历史。 搜索将返回:时间在 (startTime,endTime) 之间,消息类型为指定类型,且匹配搜索内容或消息发起者列表的一定数量的消息。
option | 搜索选项 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchAllMessageHistory | ( | String | keyword, |
List< String > | fromAccounts, | ||
long | time, | ||
int | limit | ||
) |
从本地消息数据库搜索消息历史。 该接口查询方向以某个时间点为基准从后往前,返回最多limit条匹配key的记录。
该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。
由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。
如果提供的fromAccounts参数不为空,那么凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。
keyword | 文本消息的搜索关键字 |
fromAccounts | 消息说话者帐号列表,如果消息说话在该列表中,那么无需匹配keyword,对应的消息记录会直接加入搜索结果集中。 |
time | 查询范围时间点,比time小(从后往前查) |
limit | 搜索结果的条数限制 |
InvocationFuture<List<MsgIndexRecord> > com.netease.nimlib.sdk.msg.MsgService.searchAllSession | ( | String | query, |
int | limit | ||
) |
检索所有会话,返回每个会话与检索串匹配的消息数及最近一条匹配的消息记录。(异步函数)
query | 待检索的字符串 |
limit | 最多返回多少条记录 |
List<MsgIndexRecord> com.netease.nimlib.sdk.msg.MsgService.searchAllSessionBlock | ( | String | query, |
int | limit | ||
) |
检索所有会话,返回每个会话与检索串匹配的消息数及最近一条匹配的消息记录。(同步函數)
query | 待检索的字符串 |
limit | 最多返回多少条记录 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchMessage | ( | SessionTypeEnum | sessionType, |
String | sessionId, | ||
MsgSearchOption | option | ||
) |
从本地消息数据库搜索消息历史。 搜索将返回:时间在 (startTime,endTime) 之间,消息类型为指定类型,且匹配搜索内容或消息发起者列表的一定数量的消息。
sessionType | 会话类型 |
sessionId | 聊天对象ID |
option | 搜索选项 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchMessageHistory | ( | String | keyword, |
List< String > | fromAccounts, | ||
IMMessage | anchor, | ||
int | limit | ||
) |
从本地消息数据库搜索消息历史。查询范围由anchor的sessionId和sessionType决定。
以锚点anchor作为起始点开始查询,返回最多limit条匹配key的记录。
该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。
由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。
如果提供的fromAccounts参数不为空,那么anchor对应的会话(sessionId和sessionType)的消息记录中, 凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。 注意:搜索结果不包含anchor
keyword | 文本消息的搜索关键字 |
fromAccounts | 消息说话者帐号列表,如果消息说话在该列表中,那么无需匹配keyword,对应的消息记录会直接加入搜索结果集中。 |
anchor | 搜索的消息锚点 |
limit | 搜索结果的条数限制 |
InvocationFuture<List<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchMessageHistory | ( | String | keyword, |
List< String > | fromAccounts, | ||
IMMessage | anchor, | ||
QueryDirectionEnum | direction, | ||
int | limit | ||
) |
从本地消息数据库搜索消息历史。查询范围由anchor的sessionId和sessionType决定。
该接口查询方向为从后往前。以锚点anchor作为起始点开始查询,返回最多limit条匹配key的记录。
该接口目前仅搜索文本类型的消息,匹配规则为文本内容包含keyword,仅支持精确匹配,不支持模糊匹配和拼音匹配。
由于sdk并不存储用户数据,因此keyword不会匹配用户资料。如果调用者希望查询指定用户的说话记录,可提供fromAccounts参数。
如果提供的fromAccounts参数不为空,那么anchor对应的会话(sessionId和sessionType)的消息记录中, 凡是消息说话者在fromAccounts列表中的记录,也会被当做匹配结果,加入搜索结果中。 注意:搜索结果不包含anchor
keyword | 文本消息的搜索关键字 |
fromAccounts | 消息说话者帐号列表,如果消息说话在该列表中,那么无需匹配keyword,对应的消息记录会直接加入搜索结果集中。 |
anchor | 搜索的消息锚点 |
direction | 查询方向 |
limit | 搜索结果的条数限制 |
InvocationFuture<ArrayList<IMMessage> > com.netease.nimlib.sdk.msg.MsgService.searchRoamingMsg | ( | String | otherAccid, |
long | fromTime, | ||
long | endTime, | ||
String | keyword, | ||
int | limit, | ||
boolean | reverse | ||
) |
云端聊天记录关键词查询
otherAccid | 对方的account |
fromTime | 起始时间点单位毫秒 |
endTime | 结束时间点单位毫秒 |
keyword | 搜索的关键词 |
limit | 本次查询的消息条数上限(最多100条) |
reverse | 可选参数,不传默认false,true是表示反向查询(按时间正序起查,正序排列),默认false表示按时间逆序起查,逆序排列 |
InvocationFuture<List<MsgIndexRecord> > com.netease.nimlib.sdk.msg.MsgService.searchSession | ( | String | query, |
SessionTypeEnum | sessionType, | ||
String | sessionId | ||
) |
检索指定的会话,返回该会话中与检索串匹配的所有消息记录。(异步函数)
query | 待检索的字符串 |
sessionType | 待检索的会话类型(个人/群组) |
sessionId | 待检索的会话ID |
List<MsgIndexRecord> com.netease.nimlib.sdk.msg.MsgService.searchSessionBlock | ( | String | query, |
SessionTypeEnum | sessionType, | ||
String | sessionId | ||
) |
检索指定的会话,返回该会话中与检索串匹配的所有消息记录。(同步函数)
query | 待检索的字符串 |
sessionType | 待检索的会话类型(个人/群组) |
sessionId | 待检索的会话ID |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.sendCustomNotification | ( | CustomNotification | notification | ) |
发送一条指令消息。
由于SDK仅负责透传该消息,因此不会记录指令消息状态,但可以设置回调函数监听发送结果。
notification | 指令消息 |
AbortableFuture<FileAttachment> com.netease.nimlib.sdk.msg.MsgService.sendFile | ( | FileAttachment | attachment | ) |
上传文件附件
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.sendMessage | ( | IMMessage | msg, |
boolean | resend | ||
) |
发送消息。
如果需要更新发送进度,请调用MsgServiceObserve#observeMsgStatus(com.netease.nimlib.sdk.Observer, boolean)
msg | 带发送的消息体,由MessageBuilder构造 |
resend | 如果是发送失败后重发,标记为true,否则填false |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.sendMessageReceipt | ( | String | sessionId, |
IMMessage | message | ||
) |
发送P2P消息已读回执
sessionId | 会话ID(聊天对象账号) |
message | P2P已读的消息 |
void com.netease.nimlib.sdk.msg.MsgService.setChattingAccount | ( | String | account, |
SessionTypeEnum | sessionType | ||
) |
设置当前正在聊天的对象。设置后会影响内建的消息提醒。如果有新消息到达,且消息来源是正在聊天的对象,将不会有消息提醒。
调用该接口还会附带调用clearUnreadCount(String, SessionTypeEnum),将正在聊天对象的未读数清零。
account,聊天对象帐号,或者以下两个值:<br> | MSG_CHATTING_ACCOUNT_ALL MSG_CHATTING_ACCOUNT_NONE |
sessionType | 会话类型。如果account不是具体的对象,该参数将被忽略 |
InvocationFuture<MsgPinSyncResponseOptionWrapper> com.netease.nimlib.sdk.msg.MsgService.syncMsgPin | ( | SessionTypeEnum | sessionType, |
String | sessionId, | ||
long | timestamp | ||
) |
AbortableFuture<String> com.netease.nimlib.sdk.msg.MsgService.transVoiceToText | ( | String | voiceUrl, |
String | path, | ||
long | duration | ||
) |
语音转文字
voiceUrl | 语音url。可选项。如果没有,SDK自动做nos上传工作。 |
path | 语音path, 用于获得语音采样率。APP必须保证音频已经下载到本地 |
duration | 语音时长 |
AbortableFuture<String> com.netease.nimlib.sdk.msg.MsgService.transVoiceToTextAtScene | ( | String | voiceUrl, |
String | path, | ||
long | duration, | ||
String | sceneKey | ||
) |
语音转文字并指定上传文件的场景
voiceUrl | 语音url。可选项。如果没有,SDK自动做nos上传工作。 |
path | 语音path, 用于获得语音采样率。APP必须保证音频已经下载到本地 |
duration | 语音时长 |
sceneKey | 上传文件时用的nos sceneKey ,默认值:NimNosSceneKeyConstant#NIM_DEFAULT_IM , nos token scene 配置参考NosTokenSceneConfig |
AbortableFuture<String> com.netease.nimlib.sdk.msg.MsgService.transVoiceToTextEnableForce | ( | String | voiceUrl, |
String | path, | ||
long | duration, | ||
String | sceneKey, | ||
boolean | enableForceUploadFile | ||
) |
语音转文字并指定上传文件的场景以及是否要强制重新上传文件
voiceUrl | 语音url。可选项。如果没有,SDK自动做nos上传工作。 |
path | 语音path, 用于获得语音采样率。APP必须保证音频已经下载到本地 |
duration | 语音时长 |
sceneKey | 上传文件时用的nos sceneKey ,默认值:NimNosSceneKeyConstant#NIM_DEFAULT_IM , nos token scene 配置参考NosTokenSceneConfig |
enableForceUploadFile | 如果服务器存在相同的文件,是否强制重新上传文件 ,默认false |
InvocationFuture<CollectInfo> com.netease.nimlib.sdk.msg.MsgService.updateCollect | ( | CollectInfo | info, |
String | ext | ||
) |
InvocationFuture<CollectInfo> com.netease.nimlib.sdk.msg.MsgService.updateCollect | ( | long | infoId, |
long | createTime, | ||
String | ext | ||
) |
void com.netease.nimlib.sdk.msg.MsgService.updateIMMessage | ( | IMMessage | message | ) |
更新消息。目前只能更新本地扩展字段LocalExtension
message | 待更新的消息记录 |
void com.netease.nimlib.sdk.msg.MsgService.updateIMMessageStatus | ( | IMMessage | message | ) |
更新消息记录的状态。可更新:
消息状态 IMMessage#getStatus() 不为 null 时更新
附件状态 IMMessage#getAttachStatus() 不为 null 时更新
附件内容 IMMessage#getAttachment() 不为 null 时更新
message | 待更新的消息记录 |
InvocationFuture<Long> com.netease.nimlib.sdk.msg.MsgService.updateMsgPin | ( | IMMessage | msg, |
String | ext | ||
) |
InvocationFuture<Void> com.netease.nimlib.sdk.msg.MsgService.updateMySession | ( | @NonNull String | sessionId, |
@NonNull String | ext | ||
) |
【会话服务】更新某一个会话,主要是设置会话的ext字段,如果会话不存在,则会创建出来,此时会话没有lastMsg
sessionId | 分为p2p/team/superTeam,格式分别是:p2p|accid、team|tid、super_team|tid |
ext | 会话的扩展字段,仅自己可见 |
void com.netease.nimlib.sdk.msg.MsgService.updateRecent | ( | RecentContact | recent | ) |
更新一条最近联系人会话的属性。
如果想收到MsgServiceObserve#observeRecentContact(Observer, boolean)的通知, 可使用MsgService#updateRecentAndNotify(RecentContact)
目前可设置的属性有:tag, extension
recent | 待更新的最近联系人会话数据 |
void com.netease.nimlib.sdk.msg.MsgService.updateRecentAndNotify | ( | RecentContact | recent | ) |
更新一条最近联系人会话的属性,并会触发MsgServiceObserve#observeRecentContact(Observer, boolean)的通知 。
如果仅仅是想更新最近联系人会话但不想收到通知, 可使用MsgService#updateRecent(RecentContact) 。
目前可设置的属性有:tag , extension。
recent | 待更新的最近联系人数据。 |
void com.netease.nimlib.sdk.msg.MsgService.updateRecentByMessage | ( | IMMessage | message, |
boolean | needNotify | ||
) |
通过消息更新一条最近联系人会话。
如果原来有这个会话,会保留原来的未读数以及tag相关属性
如果消息的时间比原来的会话小的话,则不会更新
message | 消息。 |
needNotify | 是否需要触发MsgServiceObserve#observeRecentContact(Observer, boolean)的通知 |
void com.netease.nimlib.sdk.msg.MsgService.updateRoamMsgHasMoreTag | ( | IMMessage | newTag | ) |
更新是否有更多漫游消息的标记
newTag | 需要有相对应的会话ID,会话类型,消息的服务ID和消息时间 |
InvocationFuture<StickTopSessionInfo> com.netease.nimlib.sdk.msg.MsgService.updateStickTopSession | ( | String | sessionId, |
SessionTypeEnum | sessionType, | ||
String | ext | ||
) |
String com.netease.nimlib.sdk.msg.MsgService.MSG_CHATTING_ACCOUNT_ALL = "all" |
目前没有与任何人对话,但能看到消息提醒(比如在消息列表界面),不需要在状态栏做消息通知
在文件 MsgService.java 第 65 行定义.
String com.netease.nimlib.sdk.msg.MsgService.MSG_CHATTING_ACCOUNT_NONE = null |
目前没有与任何人对话,需要状态栏消息通知
在文件 MsgService.java 第 72 行定义.