NIMConversationManagerProtocol.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. //
  2. // NIMConversationManager.h
  3. // NIMLib
  4. //
  5. // Created by Netease.
  6. // Copyright (c) 2015 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @class NIMMessage;
  11. @class NIMSession;
  12. @class NIMRecentSession;
  13. @class NIMRecentSessionOption;
  14. @class NIMHistoryMessageSearchOption;
  15. @class NIMMessageSearchOption;
  16. @class NIMDeleteMessagesOption;
  17. @class NIMImportedRecentSession;
  18. @class NIMMessageReceipt;
  19. @class NIMTeamMessageReceiptDetail;
  20. @class NIMClearMessagesOption;
  21. @class NIMBatchDeleteMessagesOption;
  22. @class NIMFetchServerSessionOption;
  23. @class NIMMessageServerRetrieveOption;
  24. /**
  25. * 读取服务器消息记录block
  26. *
  27. * @param error 错误,如果成功则error为nil
  28. * @param messages 读取的消息列表
  29. */
  30. typedef void(^NIMFetchMessageHistoryBlock)(NSError * __nullable error,NSArray<NIMMessage *> * __nullable messages);
  31. /**
  32. * 服务器消息检索记录block
  33. *
  34. * @param error 错误,如果成功则error为nil
  35. * @param messages 读取的消息列表
  36. */
  37. typedef void(^NIMRetrieveServerMessagesBlock)(NSError * __nullable error,NSArray<NIMMessage *> * __nullable messages);
  38. /**
  39. * 删除本地消息记录block
  40. *
  41. * @param error 错误,如果成功则error为nil
  42. */
  43. typedef void (^NIMBatchDeleteMessagesBlock)(NSError * __nullable error);
  44. /**
  45. * 更新本地消息 Block
  46. *
  47. * @param error 错误,如果成功则error为nil
  48. */
  49. typedef void(^NIMUpdateMessageBlock)(NSError * __nullable error);
  50. /**
  51. * 导入本地最近会话 Block
  52. *
  53. * @param error 错误,如果成功则error为nil
  54. * @param failedImportedRecentSessions 导入失败的最近会话
  55. */
  56. typedef void(^NIMImportRecentSessionsBlock)(NSError * __nullable error, NSArray<NIMImportedRecentSession *> * __nullable failedImportedRecentSessions);
  57. /**
  58. * 标记远端会话Block
  59. *
  60. * @param error 错误,如果成功则error为nil
  61. */
  62. typedef void(^NIMRemoveRemoteSessionBlock)(NSError * __nullable error);
  63. /**
  64. * 搜索本地消息记录Block
  65. *
  66. * @param error 错误,如果成功则error为nil
  67. * @param messages 读取的消息列表
  68. * @discussion 只有在传入参数错误时才会有error产生
  69. */
  70. typedef void(^NIMSearchMessageBlock)(NSError * __nullable error,NSArray<NIMMessage *> * __nullable messages);
  71. /**
  72. * 全局搜索本地消息记录Block
  73. *
  74. * @param error 错误,如果成功则error为nil
  75. * @param messages 读取的消息列表
  76. */
  77. typedef void(^NIMGlobalSearchMessageBlock)(NSError * __nullable error,NSDictionary<NIMSession *,NSArray<NIMMessage *> *> * __nullable messages);
  78. /**
  79. 导出历史消息进度回调
  80. @param progress 进度 0-100
  81. */
  82. typedef void(^NIMExportMessageProgress)(float progress);
  83. /**
  84. 导出历史消息完成回调
  85. @param error 错误,如果成功则为 nil
  86. @param resultFilePath 如果成功,则为结果文件路径
  87. */
  88. typedef void(^NIMExportMessageComletion)(NSError * __nullable error, NSString * __nullable resultFilePath);
  89. /**
  90. 导入历史消息进度回调
  91. @param progress 进度 0-100
  92. */
  93. typedef void(^NIMImportMessageProgress)(float progress);
  94. /**
  95. 导入历史消息完成回调
  96. @param error 错误,如果成功则为 nil
  97. */
  98. typedef void(^NIMImportMessageCompletion)(NSError * __nullable error);
  99. /**
  100. 更新服务器历史备份文件结果回调
  101. @param error 错误,如果成功则为 nil
  102. */
  103. typedef void(^NIMUpdateMigrateMessageCompletion)(NSError * __nullable error);
  104. /**
  105. 获取历史备份文件结果回调
  106. @param error 错误,如果成功则为 nil
  107. @param remoteFilePath 备份文件远端路径
  108. @param secureKey 备份文件解密的 key
  109. */
  110. typedef void(^NIMFetchMigrateMessageCompletion)(NSError * __nullable error, NSString * __nullable remoteFilePath, NSString * __nullable secureKey);
  111. /**
  112. * 读取服务器会话列表block
  113. *
  114. * @param error 错误,如果成功则error为nil
  115. * @param recentSessions 读取的消息列表
  116. * @param minTimestamp 最小时间戳只有请求第一页时会返回这个参数,表示下一次增量同步时带在请求参数里
  117. */
  118. typedef void(^NIMFetchRecentSessionsHistoryBlock)(NSError * __nullable error,
  119. NSArray<NIMRecentSession *> * __nullable recentSessions,
  120. BOOL hasMore);
  121. /**
  122. * 读取服务器会话block
  123. *
  124. * @param error 错误,如果成功则error为nil
  125. * @param recentSession 结果会话
  126. */
  127. typedef void(^NIMFetchRecentSessionHistoryBlock)(NSError * __nullable error,
  128. NIMRecentSession * _Nullable recentSession);
  129. /**
  130. * 更新服务端端会话扩展
  131. *
  132. * @param error 错误,如果成功则error为nil
  133. */
  134. typedef void(^NIMRemoteRecentSessionBlock)(NSError * __nullable error);
  135. /**
  136. 清空会话消息完成时状态回调
  137. */
  138. typedef NS_ENUM(NSUInteger, NIMClearMessagesStatus)
  139. {
  140. NIMClearMessagesStatusLocalCleared = 0,
  141. NIMClearMessagesStatusServerCleared,
  142. NIMClearMessagesStatusServerFailed,
  143. };
  144. /**
  145. * 会话管理器回调
  146. */
  147. @protocol NIMConversationManagerDelegate <NSObject>
  148. @optional
  149. /**
  150. * 最近会话数据库读取完成
  151. *
  152. * @discussion 所有最近会话读取完成。设置NIMSDKConfig中的asyncLoadRecentSessionEnabled属性为YES时,此回调会执行。
  153. * 该回调执行表示最近会话全部加载完毕可以通过allRecentSessions来取全部对话。
  154. */
  155. - (void)didLoadAllRecentSessionCompletion;
  156. /**
  157. * 增加最近会话的回调
  158. *
  159. * @param recentSession 最近会话
  160. * @param totalUnreadCount 目前总未读数
  161. * @discussion 当新增一条消息,并且本地不存在该消息所属的会话时,会触发此回调。
  162. */
  163. - (void)didAddRecentSession:(NIMRecentSession *)recentSession
  164. totalUnreadCount:(NSInteger)totalUnreadCount;
  165. /**
  166. * 最近会话修改的回调
  167. *
  168. * @param recentSession 最近会话
  169. * @param totalUnreadCount 目前总未读数
  170. * @discussion 触发条件包括: 1.当新增一条消息,并且本地存在该消息所属的会话。
  171. * 2.所属会话的未读清零。
  172. * 3.所属会话的最后一条消息的内容发送变化。(例如成功发送后,修正发送时间为服务器时间)
  173. * 4.删除消息,并且删除的消息为当前会话的最后一条消息。
  174. */
  175. - (void)didUpdateRecentSession:(NIMRecentSession *)recentSession
  176. totalUnreadCount:(NSInteger)totalUnreadCount;
  177. /**
  178. * 删除最近会话的回调
  179. *
  180. * @param recentSession 最近会话
  181. * @param totalUnreadCount 目前总未读数
  182. */
  183. - (void)didRemoveRecentSession:(NIMRecentSession *)recentSession
  184. totalUnreadCount:(NSInteger)totalUnreadCount;
  185. /**
  186. * 单个会话里所有消息被删除的回调
  187. *
  188. * @param session 消息所属会话
  189. */
  190. - (void)messagesDeletedInSession:(NIMSession *)session;
  191. /**
  192. * 所有消息被删除的回调
  193. */
  194. - (void)allMessagesDeleted;
  195. /**
  196. * 单个会话所有消息在本地和服务端都被清空
  197. * @param session 消息所属会话
  198. */
  199. - (void)allMessagesClearedInSession:(NIMSession *)session step:(NIMClearMessagesStatus)step;
  200. /**
  201. * 所有消息已读的回调
  202. */
  203. - (void)allMessagesRead;
  204. /**
  205. * 会话服务,会话更新
  206. *
  207. * @param 会话
  208. */
  209. - (void)didServerSessionUpdated:(nullable NIMRecentSession *)recentSession;
  210. @end
  211. /**
  212. 导出历史消息过程 delegate,可用于处理自定义消息
  213. */
  214. @protocol NIMExportMessageDelegate <NSObject>
  215. @optional
  216. /**
  217. 是否导出消息,YES - 导出,NO -不导出
  218. @param message 消息体
  219. @return YES / NO
  220. */
  221. - (BOOL)shouldExportMessage:(NIMMessage *)message;
  222. /**
  223. 消息导出前的通知回调
  224. @param message 将导出的消息
  225. */
  226. - (void)onMessageWillExport:(NIMMessage *)message;
  227. @end
  228. /**
  229. 导入历史消息过程 delegate,可用于处理自定义消息
  230. */
  231. @protocol NIMImportMessageDelegate <NSObject>
  232. @optional
  233. /**
  234. 是否导入消息,YES - 导入,NO -不导入
  235. @param message 消息体
  236. @return YES / NO
  237. */
  238. - (BOOL)shouldImportMessage:(NIMMessage *)message;
  239. /**
  240. 消息导入前的通知回调
  241. @param message 消息体
  242. */
  243. - (void)onMessageWillImport:(NIMMessage *)message;
  244. @end
  245. /**
  246. * 会话管理器
  247. */
  248. @protocol NIMConversationManager <NSObject>
  249. /**
  250. * 删除某条消息
  251. *
  252. * @param message 待删除的聊天消息
  253. */
  254. - (void)deleteMessage:(NIMMessage *)message;
  255. /**
  256. * 删除某个会话的所有消息
  257. *
  258. * @param session 待删除会话
  259. * @param option 删除消息选项
  260. */
  261. - (void)deleteAllmessagesInSession:(NIMSession *)session
  262. option:(nullable NIMDeleteMessagesOption *)option;
  263. /**
  264. * 删除所有会话消息
  265. *
  266. * @param option 删除消息选项
  267. * @discussion 调用这个接口只会触发allMessagesDeleted这个回调,其他针对单个recentSession的回调都不会被调用
  268. */
  269. - (void)deleteAllMessages:(nullable NIMDeleteMessagesOption *)option;
  270. /**
  271. * 删除指定范围内的消息,如指定时间范围
  272. *
  273. * @param session 目标会话
  274. * @param option 删除消息选项
  275. * @param block 完成回调
  276. */
  277. - (void)deleteMessagesInSession:(NIMSession *)session
  278. option:(nullable NIMBatchDeleteMessagesOption *)option
  279. completion:(nullable NIMBatchDeleteMessagesBlock)block;
  280. /**
  281. * 增加某个最近会话
  282. *
  283. * @param session 待增加的最近会话
  284. * @discussion 异步方法
  285. */
  286. - (void)addEmptyRecentSessionBySession:(NIMSession *)session;
  287. /**
  288. * 删除某个最近会话
  289. *
  290. * @param recentSession 待删除的最近会话
  291. * @discussion 异步方法,删除最近会话,但保留会话内消息
  292. */
  293. - (void)deleteRecentSession:(NIMRecentSession *)recentSession;
  294. /**
  295. * 设置所有会话消息为已读
  296. *
  297. * @discussion 异步方法,消息会标记为设置的状态。不会触发单条 recentSession 更新的回调,但会触发回调 - (void)allMessagesRead
  298. */
  299. - (void)markAllMessagesRead;
  300. /**
  301. * 设置一个会话里所有消息置为已读
  302. *
  303. * @param session 需设置的会话
  304. * @discussion 异步方法,消息会标记为设置的状态
  305. */
  306. - (void)markAllMessagesReadInSession:(NIMSession *)session;
  307. /**
  308. * 更新本地已存的消息记录
  309. *
  310. * @param message 需要更新的消息
  311. * @param session 需要更新的会话
  312. * @param completion 完成后的回调
  313. * @discussion 为了保证存储消息的完整性,提供给上层调用的消息更新接口只允许更新如下字段:所有消息的本地拓展字段(LocalExt)和自定义消息的消息对象(messageObject)
  314. */
  315. - (void)updateMessage:(NIMMessage *)message
  316. forSession:(NIMSession *)session
  317. completion:(nullable NIMUpdateMessageBlock)completion;
  318. /**
  319. * 写入消息
  320. *
  321. * @param message 需要更新的消息
  322. * @param session 需要更新的会话
  323. * @param completion 完成后的回调
  324. * @discussion 当保存消息成功之后,会收到 NIMChatManagerDelegate 中的 onRecvMessages: 回调。不允许插入已存在的消息
  325. */
  326. - (void)saveMessage:(NIMMessage *)message
  327. forSession:(NIMSession *)session
  328. completion:(nullable NIMUpdateMessageBlock)completion;
  329. /**
  330. * 导入最近会话
  331. *
  332. * @param importedRecentSession 待导入的会话集合
  333. * @param completion 完成后的回调
  334. * @discussion 当导入最近会话成功之后,不会收到 NIMChatManagerDelegate 中的 recentSession 变化的回调,请直接在 completion 中做处理。不允许插入已经存在的最近会话。
  335. */
  336. - (void)importRecentSessions:(NSArray<NIMImportedRecentSession *> *)importedRecentSession
  337. completion:(nullable NIMImportRecentSessionsBlock)completion;
  338. /**
  339. * 从本地db读取一个会话里某条消息之前的若干条的消息
  340. *
  341. * @param session 消息所属的会话
  342. * @param message 当前最早的消息,没有则传入nil
  343. * @param limit 个数限制
  344. *
  345. * @return 消息列表,按时间从小到大排列
  346. */
  347. - (nullable NSArray<NIMMessage *> *)messagesInSession:(NIMSession *)session
  348. message:(nullable NIMMessage *)message
  349. limit:(NSInteger)limit;
  350. /**
  351. * 根据消息Id获取消息
  352. *
  353. * @param session 消息所属会话结合
  354. *
  355. * @param messageIds 消息Id集合
  356. *
  357. * @return 消息列表,按时间从小到大排列
  358. */
  359. - (nullable NSArray<NIMMessage *> *)messagesInSession:(NIMSession *)session
  360. messageIds:(NSArray<NSString *> *)messageIds;
  361. /**
  362. * 获取所有未读数
  363. * @discussion 只能在主线程调用,包括忽略提醒的会话
  364. * @return 未读数
  365. */
  366. - (NSInteger)allUnreadCount;
  367. /**
  368. * 获取所有需要通知/不需要通知的最近会话未读数
  369. * @param notify 是否需要通知
  370. * @return 未读数
  371. * @discussion 群只有 notify state != NIMTeamNotifyStateNone 才算是不允许通知
  372. */
  373. - (NSInteger)allUnreadCount:(BOOL)notify;
  374. /**
  375. * 获取所有最近会话。
  376. * @return 最近会话列表
  377. * @discussion SDK 以 map 的形式保存 sessions,调用这个方法时将进行排序,数据量较大 (上万) 时会比较耗时。
  378. * 该方法默认是同步查询所有sessions,当数据量较大(上万)会比较耗时,可能会卡主线程,这种情况下
  379. * 用户可以配置NIMSDKConfig中的asyncLoadRecentSessionEnabled属性为YES,此时该接口可以先返回
  380. * 100条最近会话,等全部加载完会回调didLoadAllRecentSessionCompletion,此后再调用该接口可以全量返回
  381. * 所有会话,用户需要在didLoadAllRecentSessionCompletion回调中及时更新UI展示。
  382. */
  383. - (nullable NSArray<NIMRecentSession *> *)allRecentSessions;
  384. /**
  385. * 获取所有最近会话
  386. * @return 最近会话列表
  387. * @discussion SDK 以 map 的形式保存 sessions,调用这个方法时将进行排序,数据量较大 (上万) 时会比较耗时。
  388. * 通过该接口获取的最近会话列表与allRecentSessions接口不同,是基于allRecentSessions接口筛选类型之后重新生成的新对象
  389. * 需要用户自行在外部管理,所有回调不回回调该接口查询的任何会话
  390. */
  391. - (nullable NSArray<NIMRecentSession *> *)allRecentSessionsWithOption:(NIMRecentSessionOption *)option;
  392. /**
  393. * 根据当前 session 返回对应的最近会话信息
  394. *
  395. * @param session 会话
  396. *
  397. * @return 最近会话信息,如果找不到则返回 nil
  398. */
  399. - (nullable NIMRecentSession *)recentSessionBySession:(NIMSession *)session;
  400. /**
  401. * 从服务端分页获取历史会话列表
  402. *
  403. * @param option 分页查询选项,可为空,空时默认全量获取
  404. *
  405. * @param completion 完成回调
  406. */
  407. - (void)fetchServerSessions:(nullable NIMFetchServerSessionOption *)option
  408. completion:(nullable NIMFetchRecentSessionsHistoryBlock)completion;
  409. /**
  410. * 从服务端获取会话信息
  411. *
  412. * @param session 目标会话
  413. *
  414. * @param completion 完成回调
  415. */
  416. - (void)fetchServerSessionBySession:(NIMSession *)session
  417. completion:(nullable NIMFetchRecentSessionHistoryBlock)completion;
  418. /**
  419. * 更新服务端获取会话扩展信息
  420. *
  421. * @param ext 扩展信息
  422. *
  423. * @param session 目标最近会话
  424. *
  425. * @param completion 完成回调
  426. */
  427. - (void)updateServerSessionExt:(NSString *)ext
  428. session:(NIMSession *)session
  429. completion:(nullable NIMRemoteRecentSessionBlock)completion;
  430. /**
  431. * 删除服务端
  432. *
  433. * @param sessions 目标会话
  434. *
  435. * @param completion 完成回调
  436. */
  437. - (void)deleteServerSessions:(NSArray<NIMSession *> *)sessions
  438. completion:(nullable NIMRemoteRecentSessionBlock)completion;
  439. /**
  440. * 从服务器上获取一个会话里某条消息之前的若干条的消息
  441. *
  442. * @param session 消息所属的会话
  443. * @param option 搜索选项
  444. * @param result 读取的消息列表结果
  445. * @discussion 此接口不支持查询聊天室消息,聊天室请参考 NIMChatroomManagerProtocol 中的查询消息接口。
  446. *
  447. */
  448. - (void)fetchMessageHistory:(NIMSession *)session
  449. option:(NIMHistoryMessageSearchOption *)option
  450. result:(nullable NIMFetchMessageHistoryBlock)result;
  451. /**
  452. * 根据关键字从服务器上检索消息
  453. *
  454. * @param session 消息所属的会话
  455. * @param option 检索选项
  456. * @param result 读取的消息列表结果
  457. * @discussion 检索消息内容,大小写不敏感;此接口不支持查询聊天室消息,聊天室请参考 NIMChatroomManagerProtocol 中的消息接口。
  458. *
  459. */
  460. - (void)retrieveServerMessages:(NIMSession *)session
  461. option:(NIMMessageServerRetrieveOption *)option
  462. result:(nullable NIMRetrieveServerMessagesBlock)result;
  463. /**
  464. * 搜索本地会话内消息
  465. *
  466. * @param session 消息所属的会话
  467. * @param option 搜索选项
  468. * @param result 读取的消息列表结果
  469. *
  470. */
  471. - (void)searchMessages:(NIMSession *)session
  472. option:(NIMMessageSearchOption *)option
  473. result:(nullable NIMSearchMessageBlock)result;
  474. /**
  475. * 全局搜索本地消息
  476. *
  477. * @param option 搜索选项
  478. * @param result 读取的消息内容
  479. */
  480. - (void)searchAllMessages:(NIMMessageSearchOption *)option
  481. result:(nullable NIMGlobalSearchMessageBlock)result;
  482. /**
  483. * 删除服务器端最近会话
  484. *
  485. * @param sessions 需要删除的会话列表,内部只能是NIMSession
  486. * @param completion 完成的回调
  487. * @discussion 调用这个接口成功后,当前会话之前的消息都不会漫游到其他端
  488. */
  489. - (void)deleteRemoteSessions:(NSArray<NIMSession *> *)sessions
  490. completion:(nullable NIMRemoveRemoteSessionBlock)completion;
  491. /**
  492. * 清空点对点会话对应本地和服务端的消息
  493. *
  494. * @param session 目标会话列表
  495. * @param option 清空消息选项
  496. * @param completion 完成回调
  497. * @discussion 只支持点对点,清空本用户的本地和服务端消息,不影响对方;如果不设置清空选项,服务端默认会同时清空漫游消息;
  498. */
  499. - (void)deleteSelfRemoteSession:(NIMSession *)session
  500. option:(nullable NIMClearMessagesOption *)option
  501. completion:(nullable NIMRemoveRemoteSessionBlock)completion;
  502. /**
  503. * 更新最近会话的本地扩展
  504. *
  505. * @param ext 扩展信息
  506. * @param recentSession 要更新的最近会话
  507. * @discussion 此扩展不会漫游到其他端,上层需要保证 NSDictionary 可以转换为 JSON。
  508. */
  509. - (void)updateRecentLocalExt:(nullable NSDictionary *)ext
  510. recentSession:(NIMRecentSession *)recentSession;
  511. /**
  512. 导出历史消息到本地文件
  513. @param delegate 自定义消息的处理 delegate
  514. @param progress 导出进度更新回调
  515. @param completion 导出完成回调
  516. */
  517. - (void)exportMeessageInfosWithDelegate:(id<NIMExportMessageDelegate>)delegate
  518. progress:(NIMExportMessageProgress)progress
  519. completion:(NIMExportMessageComletion)completion;
  520. /**
  521. 导入历史消息
  522. @param infoFilePath 已解码并序列化了的本地历史消息文件路径
  523. @param delegate 自定义消息的处理 delegate
  524. @param progress 导入进度更新回调
  525. @param completion 导入完成回调
  526. */
  527. - (void)importMessageInfosAtPath:(NSString *)infoFilePath
  528. delegate:(id<NIMImportMessageDelegate>)delegate
  529. progress:(NIMImportMessageProgress)progress
  530. completion:(NIMImportMessageCompletion)completion;
  531. /**
  532. 取消 导出/导入 历史消息操作
  533. */
  534. - (void)cancelMigrateMessages;
  535. /**
  536. 更新历史消息备份信息
  537. @param URL 历史消息备份的 URL
  538. @param key 历史消息备份的加密 key
  539. @param completion 更新信息的完成回调
  540. */
  541. - (void)updateMigrateMessageInfoWithURL:(NSString *)URL key:(NSString *)key completion:(NIMUpdateMigrateMessageCompletion)completion;
  542. /**
  543. 获取历史消息备份信息
  544. @param completion 获取历史消息备份的完成回调
  545. */
  546. - (void)fetchMigrateMessageInfo:(NIMFetchMigrateMessageCompletion)completion;
  547. /**
  548. 反序列化消息数据
  549. @param encodeData 序列化的数据
  550. @return 消息对象
  551. @discussion 此接口用于反序列化消息的数据,请与encodeMessageToData配套使用,用于实现消息本地序列化
  552. */
  553. - (NIMMessage *)decodeMessageFromData:(NSData *)encodeData;
  554. /**
  555. 序列化消息
  556. @param message 消息对象
  557. @return 序列化数据
  558. @discussion 此接口用于序列化消息,请与decodeMessageFromData配套使用,用于实现消息本地序列化
  559. */
  560. - (NSData *)encodeMessageToData:(NIMMessage *)message;
  561. /**
  562. * 添加通知对象
  563. *
  564. * @param delegate 通知对象
  565. */
  566. - (void)addDelegate:(id<NIMConversationManagerDelegate>)delegate;
  567. /**
  568. * 删除通知对象
  569. *
  570. * @param delegate 通知对象
  571. */
  572. - (void)removeDelegate:(id<NIMConversationManagerDelegate>)delegate;
  573. @end
  574. NS_ASSUME_NONNULL_END