IEMChatManager.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. /*!
  2. * \~chinese
  3. * @header IEMChatManager.h
  4. * @abstract 此协议定义了聊天相关操作
  5. * @author Hyphenate
  6. * @version 3.00
  7. *
  8. * \~english
  9. * @header IEMChatManager.h
  10. * @abstract This protocol defines the operations of chat
  11. * @author Hyphenate
  12. * @version 3.00
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "EMCommonDefs.h"
  16. #import "EMChatManagerDelegate.h"
  17. #import "EMConversation.h"
  18. #import "EMMessage.h"
  19. #import "EMTextMessageBody.h"
  20. #import "EMLocationMessageBody.h"
  21. #import "EMCmdMessageBody.h"
  22. #import "EMFileMessageBody.h"
  23. #import "EMImageMessageBody.h"
  24. #import "EMVoiceMessageBody.h"
  25. #import "EMVideoMessageBody.h"
  26. #import "EMCursorResult.h"
  27. #import "EMGroupMessageAck.h"
  28. @class EMError;
  29. /*!
  30. * \~chinese
  31. * 聊天相关操作
  32. * 目前消息都是从DB中加载,沒有從server端加载
  33. *
  34. * \~english
  35. * Operations of chat
  36. * Current message are loaded from local database, not from server
  37. */
  38. @protocol IEMChatManager <NSObject>
  39. @required
  40. #pragma mark - Delegate
  41. /*!
  42. * \~chinese
  43. * 添加回调代理
  44. *
  45. * @param aDelegate 要添加的代理
  46. * @param aQueue 执行代理方法的队列
  47. *
  48. * \~english
  49. * Add delegate
  50. *
  51. * @param aDelegate Delegate
  52. * @param aQueue (optional) The queue of calling delegate methods. Pass in nil to run on main thread.
  53. */
  54. - (void)addDelegate:(id<EMChatManagerDelegate>)aDelegate
  55. delegateQueue:(dispatch_queue_t)aQueue;
  56. /*!
  57. * \~chinese
  58. * 移除回调代理
  59. *
  60. * @param aDelegate 要移除的代理
  61. *
  62. * \~english
  63. * Remove delegate
  64. *
  65. * @param aDelegate Delegate
  66. */
  67. - (void)removeDelegate:(id<EMChatManagerDelegate>)aDelegate;
  68. #pragma mark - Conversation
  69. /*!
  70. * \~chinese
  71. * 获取所有会话,如果内存中不存在会从DB中加载
  72. *
  73. * @result 会话列表<EMConversation>
  74. *
  75. * \~english
  76. * Get all conversations from local databse. Will load conversations from cache first, otherwise local database
  77. *
  78. * @result Conversation list<EMConversation>
  79. */
  80. - (NSArray *)getAllConversations;
  81. /*!
  82. * \~chinese
  83. * 获取一个会话
  84. *
  85. * @param aConversationId 会话ID
  86. * @param aType 会话类型
  87. * @param aIfCreate 如果不存在是否创建
  88. *
  89. * @result 会话对象
  90. *
  91. * \~english
  92. * Get a conversation from local database
  93. *
  94. * @param aConversationId Conversation id
  95. * @param aType Conversation type (Must be specified)
  96. * @param aIfCreate Whether create conversation if not exist
  97. *
  98. * @result Conversation
  99. */
  100. - (EMConversation *)getConversation:(NSString *)aConversationId
  101. type:(EMConversationType)aType
  102. createIfNotExist:(BOOL)aIfCreate;
  103. /*!
  104. * \~chinese
  105. * 删除会话
  106. *
  107. * @param aConversationId 会话ID
  108. * @param aIsDeleteMessages 是否删除会话中的消息
  109. * @param aCompletionBlock 完成的回调
  110. *
  111. * \~english
  112. * Delete a conversation from local database
  113. *
  114. * @param aConversationId Conversation id
  115. * @param aIsDeleteMessages if delete messages
  116. * @param aCompletionBlock The callback of completion block
  117. *
  118. */
  119. - (void)deleteConversation:(NSString *)aConversationId
  120. isDeleteMessages:(BOOL)aIsDeleteMessages
  121. completion:(void (^)(NSString *aConversationId, EMError *aError))aCompletionBlock;
  122. /*!
  123. * \~chinese
  124. * 删除一组会话
  125. *
  126. * @param aConversations 会话列表<EMConversation>
  127. * @param aIsDeleteMessages 是否删除会话中的消息
  128. * @param aCompletionBlock 完成的回调
  129. *
  130. * \~english
  131. * Delete multiple conversations
  132. *
  133. * @param aConversations Conversation list<EMConversation>
  134. * @param aIsDeleteMessages Whether delete messages
  135. * @param aCompletionBlock The callback of completion block
  136. *
  137. */
  138. - (void)deleteConversations:(NSArray *)aConversations
  139. isDeleteMessages:(BOOL)aIsDeleteMessages
  140. completion:(void (^)(EMError *aError))aCompletionBlock;
  141. /*!
  142. * \~chinese
  143. * 导入一组会话到DB
  144. *
  145. * @param aConversations 会话列表<EMConversation>
  146. * @param aCompletionBlock 完成的回调
  147. *
  148. *
  149. * \~english
  150. * Import multiple conversations to local database
  151. *
  152. * @param aConversations Conversation list<EMConversation>
  153. * @param aCompletionBlock The callback of completion block
  154. *
  155. */
  156. - (void)importConversations:(NSArray *)aConversations
  157. completion:(void (^)(EMError *aError))aCompletionBlock;
  158. #pragma mark - Message
  159. - (EMMessage *)getMessageWithMessageId:(NSString *)aMessageId;
  160. /*!
  161. * \~chinese
  162. * 获取消息附件路径,存在这个路径的文件,删除会话时会被删除
  163. *
  164. * @param aConversationId 会话ID
  165. *
  166. * @result 附件路径
  167. *
  168. * \~english
  169. * Get message attachment local path for the conversation. Delete the conversation will also delete the files under the file path
  170. *
  171. * @param aConversationId Conversation id
  172. *
  173. * @result Attachment path
  174. */
  175. - (NSString *)getMessageAttachmentPath:(NSString *)aConversationId;
  176. /*!
  177. * \~chinese
  178. * 导入一组消息到DB
  179. *
  180. * @param aMessages 消息列表<EMMessage>
  181. * @param aCompletionBlock 完成的回调
  182. *
  183. * \~english
  184. * Import multiple messages to local database
  185. *
  186. * @param aMessages Message list<EMMessage>
  187. * @param aCompletionBlock The callback of completion block
  188. *
  189. */
  190. - (void)importMessages:(NSArray *)aMessages
  191. completion:(void (^)(EMError *aError))aCompletionBlock;
  192. /*!
  193. * \~chinese
  194. * 更新消息到DB
  195. *
  196. * @param aMessage 消息
  197. * @param aCompletionBlock 完成的回调
  198. *
  199. * \~english
  200. * Update a message in local database. latestMessage of the conversation and other properties will be updated accordingly. messageId of the message cannot be updated
  201. *
  202. * @param aMessage Message
  203. * @param aCompletionBlock The callback of completion block
  204. *
  205. */
  206. - (void)updateMessage:(EMMessage *)aMessage
  207. completion:(void (^)(EMMessage *aMessage, EMError *aError))aCompletionBlock;
  208. /*!
  209. * \~chinese
  210. * 发送消息已读回执
  211. *
  212. * 异步方法
  213. *
  214. * @param aMessage 消息id
  215. * @param aUsername 已读接收方
  216. * @param aCompletionBlock 完成的回调
  217. *
  218. * \~english
  219. * Send read acknowledgement for message
  220. *
  221. * @param aMessageId Message id
  222. * @param aUsername ack receiver
  223. * @param aCompletionBlock The callback of completion block
  224. *
  225. */
  226. - (void)sendMessageReadAck:(NSString *)aMessageId
  227. toUser:(NSString *)aUsername
  228. completion:(void (^)(EMError *aError))aCompletionBlock;
  229. /*!
  230. * \~chinese
  231. * 发送群消息已读回执
  232. *
  233. * 异步方法
  234. *
  235. * @param aMessageId 消息id
  236. * @param aGroupId 群id
  237. * @param aContent 附加消息
  238. * @param aCompletionBlock 完成的回调
  239. *
  240. * \~english
  241. * Send read acknowledgement for message
  242. *
  243. * @param aMessageId Message id
  244. * @param aGroupId group receiver
  245. * @param aContent Content
  246. * @param aCompletionBlock The callback of completion block
  247. *
  248. */
  249. - (void)sendGroupMessageReadAck:(NSString *)aMessageId
  250. toGroup:(NSString *)aGroupId
  251. content:(NSString *)aContent
  252. completion:(void (^)(EMError *aError))aCompletionBlock;
  253. /*!
  254. * \~chinese
  255. * 撤回消息
  256. *
  257. * 异步方法
  258. *
  259. * @param aMessageId 消息Id
  260. * @param aCompletionBlock 完成的回调
  261. *
  262. * \~english
  263. * Recall a message
  264. *
  265. *
  266. * @param aMessageId Message id
  267. * @param aCompletionBlock The callback block of completion
  268. *
  269. */
  270. - (void)recallMessageWithMessageId:(NSString *)aMessageId
  271. completion:(void (^)(EMError *aError))aCompletionBlock;
  272. /*!
  273. * \~chinese
  274. * 发送消息
  275. *
  276. * @param aMessage 消息
  277. * @param aProgressBlock 附件上传进度回调block
  278. * @param aCompletionBlock 发送完成回调block
  279. *
  280. * \~english
  281. * Send a message
  282. *
  283. * @param aMessage Message instance
  284. * @param aProgressBlock The block of attachment upload progress in percentage, 0~100.
  285. * @param aCompletionBlock The callback of completion block
  286. */
  287. - (void)sendMessage:(EMMessage *)aMessage
  288. progress:(void (^)(int progress))aProgressBlock
  289. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  290. /*!
  291. * \~chinese
  292. * 重发送消息
  293. *
  294. * @param aMessage 消息
  295. * @param aProgressBlock 附件上传进度回调block
  296. * @param aCompletionBlock 发送完成回调block
  297. *
  298. * \~english
  299. * Resend Message
  300. *
  301. * @param aMessage Message instance
  302. * @param aProgressBlock The callback block of attachment upload progress
  303. * @param aCompletionBlock The callback of completion block
  304. */
  305. - (void)resendMessage:(EMMessage *)aMessage
  306. progress:(void (^)(int progress))aProgressBlock
  307. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  308. /*!
  309. * \~chinese
  310. * 下载缩略图(图片消息的缩略图或视频消息的第一帧图片),SDK会自动下载缩略图,所以除非自动下载失败,用户不需要自己下载缩略图
  311. *
  312. * @param aMessage 消息
  313. * @param aProgressBlock 附件下载进度回调block
  314. * @param aCompletionBlock 下载完成回调block
  315. *
  316. * \~english
  317. * Manual download the message thumbnail (thumbnail of image message or first frame of video image).
  318. * SDK handles the thumbnail downloading automatically, no need to download thumbnail manually unless automatic download failed.
  319. *
  320. * @param aMessage Message instance
  321. * @param aProgressBlock The callback block of attachment download progress
  322. * @param aCompletionBlock The callback of completion block
  323. */
  324. - (void)downloadMessageThumbnail:(EMMessage *)aMessage
  325. progress:(void (^)(int progress))aProgressBlock
  326. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  327. /*!
  328. * \~chinese
  329. * 下载消息附件(语音,视频,图片原图,文件),SDK会自动下载语音消息,所以除非自动下载语音失败,用户不需要自动下载语音附件
  330. *
  331. * 异步方法
  332. *
  333. * @param aMessage 消息
  334. * @param aProgressBlock 附件下载进度回调block
  335. * @param aCompletionBlock 下载完成回调block
  336. *
  337. * \~english
  338. * Download message attachment (voice, video, image or file). SDK handles attachment downloading automatically, no need to download attachment manually unless automatic download failed
  339. *
  340. * @param aMessage Message object
  341. * @param aProgressBlock The callback block of attachment download progress
  342. * @param aCompletionBlock The callback of completion block
  343. */
  344. - (void)downloadMessageAttachment:(EMMessage *)aMessage
  345. progress:(void (^)(int progress))aProgressBlock
  346. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  347. /**
  348. * \~chinese
  349. * 从服务器获取指定会话的历史消息
  350. *
  351. * @param aConversationId 要获取漫游消息的Conversation id
  352. * @param aConversationType 要获取漫游消息的Conversation type
  353. * @param aStartMessageId 参考起始消息的ID
  354. * @param aPageSize 获取消息条数
  355. * @param pError 错误信息
  356. *
  357. * @return 获取的消息结果
  358. *
  359. *
  360. * \~english
  361. * Fetch conversation roam messages from server.
  362. * @param aConversationId The conversation id which select to fetch roam message.
  363. * @param aConversationType The conversation type which select to fetch roam message.
  364. * @param aStartMessageId The start search roam message, if empty start from the server leastst message.
  365. * @param aPageSize The page size.
  366. * @param pError EMError used for output.
  367. *
  368. * @return The result
  369. */
  370. - (EMCursorResult *)fetchHistoryMessagesFromServer:(NSString *)aConversationId
  371. conversationType:(EMConversationType)aConversationType
  372. startMessageId:(NSString *)aStartMessageId
  373. pageSize:(int)aPageSize
  374. error:(EMError **)pError;
  375. /**
  376. * \~chinese
  377. * 从服务器获取指定会话的历史消息
  378. *
  379. * 异步方法
  380. *
  381. * @param aConversationId 要获取漫游消息的Conversation id
  382. * @param aConversationType 要获取漫游消息的Conversation type
  383. * @param aStartMessageId 参考起始消息的ID
  384. * @param aPageSize 获取消息条数
  385. * @param aCompletionBlock 获取消息结束的callback
  386. *
  387. *
  388. * \~english
  389. * Fetch conversation roam messages from server.
  390. * @param aConversationId The conversation id which select to fetch roam message.
  391. * @param aConversationType The conversation type which select to fetch roam message.
  392. * @param aStartMessageId The start search roam message, if empty start from the server leastst message.
  393. * @param aPageSize The page size.
  394. * @param aCompletionBlock The callback block of fetch complete
  395. */
  396. - (void)asyncFetchHistoryMessagesFromServer:(NSString *)aConversationId
  397. conversationType:(EMConversationType)aConversationType
  398. startMessageId:(NSString *)aStartMessageId
  399. pageSize:(int)aPageSize
  400. completion:(void (^)(EMCursorResult *aResult, EMError *aError))aCompletionBlock;
  401. - (void)asyncFetchGroupMessageAcksFromServer:(NSString *)aMessageId
  402. groupId:(NSString *)aGroupId
  403. startGroupAckId:(NSString *)aGroupAckId
  404. pageSize:(int)aPageSize
  405. completion:(void (^)(EMCursorResult *aResult, EMError *error, int totalCount))aCompletionBlock;
  406. #pragma mark - EM_DEPRECATED_IOS 3.6.1
  407. /*!
  408. * \~chinese
  409. * 发送消息已读回执
  410. *
  411. * 异步方法
  412. *
  413. * @param aMessage 消息
  414. * @param aCompletionBlock 完成的回调
  415. *
  416. * \~english
  417. * Send read acknowledgement for message
  418. *
  419. * @param aMessage Message instance
  420. * @param aCompletionBlock The callback of completion block
  421. *
  422. */
  423. - (void)sendMessageReadAck:(EMMessage *)aMessage
  424. completion:(void (^)(EMMessage *aMessage, EMError *aError))aCompletionBlock EM_DEPRECATED_IOS(3_3_0, 3_6_1, "Use -[IEMChatManager sendMessageReadAck:toUser:completion:]");
  425. /*!
  426. * \~chinese
  427. * 撤回消息
  428. *
  429. * 异步方法
  430. *
  431. * @param aMessage 消息
  432. * @param aCompletionBlock 完成的回调
  433. *
  434. * \~english
  435. * Recall a message
  436. *
  437. *
  438. * @param aMessage Message instance
  439. * @param aCompletionBlock The callback block of completion
  440. *
  441. */
  442. - (void)recallMessage:(EMMessage *)aMessage
  443. completion:(void (^)(EMMessage *aMessage, EMError *aError))aCompletionBlock EM_DEPRECATED_IOS(3_3_0, 3_6_1, "Use -[IEMChatManager recallMessageWithMessageId:completion:]");
  444. #pragma mark - EM_DEPRECATED_IOS 3.2.3
  445. /*!
  446. * \~chinese
  447. * 添加回调代理
  448. *
  449. * @param aDelegate 要添加的代理
  450. *
  451. * \~english
  452. * Add delegate
  453. *
  454. * @param aDelegate Delegate
  455. */
  456. - (void)addDelegate:(id<EMChatManagerDelegate>)aDelegate EM_DEPRECATED_IOS(3_1_0, 3_2_2, "Use -[IEMChatManager addDelegate:delegateQueue:]");
  457. #pragma mark - EM_DEPRECATED_IOS < 3.2.3
  458. /*!
  459. * \~chinese
  460. * 从数据库中获取所有的会话,执行后会更新内存中的会话列表
  461. *
  462. * 同步方法,会阻塞当前线程
  463. *
  464. * @result 会话列表<EMConversation>
  465. *
  466. * \~english
  467. * Load all conversations from DB, will update conversation list in memory after this method is called
  468. *
  469. * Synchronization method will block the current thread
  470. *
  471. * @result Conversation list<EMConversation>
  472. */
  473. - (NSArray *)loadAllConversationsFromDB __deprecated_msg("Use -getAllConversations");
  474. /*!
  475. * \~chinese
  476. * 删除会话
  477. *
  478. * @param aConversationId 会话ID
  479. * @param aDeleteMessage 是否删除会话中的消息
  480. *
  481. * @result 是否成功
  482. *
  483. * \~english
  484. * Delete a conversation
  485. *
  486. * @param aConversationId Conversation id
  487. * @param aDeleteMessage Whether delete messages
  488. *
  489. * @result Whether deleted successfully
  490. */
  491. - (BOOL)deleteConversation:(NSString *)aConversationId
  492. deleteMessages:(BOOL)aDeleteMessage __deprecated_msg("Use -deleteConversation:isDeleteMessages:completion:");
  493. /*!
  494. * \~chinese
  495. * 删除一组会话
  496. *
  497. * @param aConversations 会话列表<EMConversation>
  498. * @param aDeleteMessage 是否删除会话中的消息
  499. *
  500. * @result 是否成功
  501. *
  502. * \~english
  503. * Delete multiple conversations
  504. *
  505. * @param aConversations Conversation list<EMConversation>
  506. * @param aDeleteMessage Whether delete messages
  507. *
  508. * @result Whether deleted successfully
  509. */
  510. - (BOOL)deleteConversations:(NSArray *)aConversations
  511. deleteMessages:(BOOL)aDeleteMessage __deprecated_msg("Use -deleteConversations:isDeleteMessages:completion:");
  512. /*!
  513. * \~chinese
  514. * 导入一组会话到DB
  515. *
  516. * @param aConversations 会话列表<EMConversation>
  517. *
  518. * @result 是否成功
  519. *
  520. * \~english
  521. * Import multiple conversations to DB
  522. *
  523. * @param aConversations Conversation list<EMConversation>
  524. *
  525. * @result Whether imported successfully
  526. */
  527. - (BOOL)importConversations:(NSArray *)aConversations __deprecated_msg("Use -importConversations:completion:");
  528. /*!
  529. * \~chinese
  530. * 导入一组消息到DB
  531. *
  532. * @param aMessages 消息列表<EMMessage>
  533. *
  534. * @result 是否成功
  535. *
  536. * \~english
  537. * Import multiple messages
  538. *
  539. * @param aMessages Message list<EMMessage>
  540. *
  541. * @result Whether imported successfully
  542. */
  543. - (BOOL)importMessages:(NSArray *)aMessages __deprecated_msg("Use -importMessages:completion:");
  544. /*!
  545. * \~chinese
  546. * 更新消息到DB
  547. *
  548. * @param aMessage 消息
  549. *
  550. * @result 是否成功
  551. *
  552. * \~english
  553. * Update message to DB
  554. *
  555. * @param aMessage Message
  556. *
  557. * @result Whether updated successfully
  558. */
  559. - (BOOL)updateMessage:(EMMessage *)aMessage __deprecated_msg("Use -updateMessage:completion:");
  560. /*!
  561. * \~chinese
  562. * 发送消息已读回执
  563. *
  564. * 异步方法
  565. *
  566. * @param aMessage 消息
  567. *
  568. * \~english
  569. * Send read ack for message
  570. *
  571. * Asynchronous methods
  572. *
  573. * @param aMessage Message instance
  574. */
  575. - (void)asyncSendReadAckForMessage:(EMMessage *)aMessage __deprecated_msg("Use -sendMessageReadAck:completion:");
  576. /*!
  577. * \~chinese
  578. * 发送消息
  579. *
  580. * 异步方法
  581. *
  582. * @param aMessage 消息
  583. * @param aProgressCompletion 附件上传进度回调block
  584. * @param aCompletion 发送完成回调block
  585. *
  586. * \~english
  587. * Send a message
  588. *
  589. * Asynchronous methods
  590. *
  591. * @param aMessage Message instance
  592. * @param aProgressCompletion The block of attachment upload progress
  593. *
  594. * @param aCompletion The block of send complete
  595. */
  596. - (void)asyncSendMessage:(EMMessage *)aMessage
  597. progress:(void (^)(int progress))aProgressCompletion
  598. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -sendMessage:progress:completion:");
  599. /*!
  600. * \~chinese
  601. * 重发送消息
  602. *
  603. * 异步方法
  604. *
  605. * @param aMessage 消息
  606. * @param aProgressCompletion 附件上传进度回调block
  607. * @param aCompletion 发送完成回调block
  608. *
  609. * \~english
  610. * Resend Message
  611. *
  612. * Asynchronous methods
  613. *
  614. * @param aMessage Message instance
  615. * @param aProgressCompletion The callback block of attachment upload progress
  616. * @param aCompletion The callback block of send complete
  617. */
  618. - (void)asyncResendMessage:(EMMessage *)aMessage
  619. progress:(void (^)(int progress))aProgressCompletion
  620. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -resendMessage:progress:completion:");
  621. /*!
  622. * \~chinese
  623. * 下载缩略图(图片消息的缩略图或视频消息的第一帧图片),SDK会自动下载缩略图,所以除非自动下载失败,用户不需要自己下载缩略图
  624. *
  625. * 异步方法
  626. *
  627. * @param aMessage 消息
  628. * @param aProgressCompletion 附件下载进度回调block
  629. * @param aCompletion 下载完成回调block
  630. *
  631. * \~english
  632. * Download message thumbnail attachments (thumbnails of image message or first frame of video image), SDK can download thumbail automatically, so user should NOT download thumbail manually except automatic download failed
  633. *
  634. * Asynchronous methods
  635. *
  636. * @param aMessage Message instance
  637. * @param aProgressCompletion The callback block of attachment download progress
  638. * @param aCompletion The callback block of download complete
  639. */
  640. - (void)asyncDownloadMessageThumbnail:(EMMessage *)aMessage
  641. progress:(void (^)(int progress))aProgressCompletion
  642. completion:(void (^)(EMMessage * message, EMError *error))aCompletion __deprecated_msg("Use -downloadMessageThumbnail:progress:completion:");
  643. /*!
  644. * \~chinese
  645. * 下载消息附件(语音,视频,图片原图,文件),SDK会自动下载语音消息,所以除非自动下载语音失败,用户不需要自动下载语音附件
  646. *
  647. * 异步方法
  648. *
  649. * @param aMessage 消息
  650. * @param aProgressCompletion 附件下载进度回调block
  651. * @param aCompletion 下载完成回调block
  652. *
  653. * \~english
  654. * Download message attachment(voice, video, image or file), SDK can download voice automatically, so user should NOT download voice manually except automatic download failed
  655. *
  656. * Asynchronous methods
  657. *
  658. * @param aMessage Message instance
  659. * @param aProgressCompletion The callback block of attachment download progress
  660. * @param aCompletion The callback block of download complete
  661. */
  662. - (void)asyncDownloadMessageAttachments:(EMMessage *)aMessage
  663. progress:(void (^)(int progress))aProgressCompletion
  664. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -downloadMessageAttachment:progress:completion");
  665. /*!
  666. * \~chinese
  667. * 从数据库获取指定类型的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息取,如果aCount小于等于0当作1处理
  668. *
  669. * @param aType 消息类型
  670. * @param aTimestamp 参考时间戳
  671. * @param aCount 获取的条数
  672. * @param aUsername 消息发送方,如果为空则忽略
  673. * @param aDirection 消息搜索方向
  674. * @param aCompletionBlock 完成的回调
  675. *
  676. * \~english
  677. * Load messages with specified message type from local database. Returning messages are sorted by receiving timestamp based on EMMessageSearchDirection.
  678. *
  679. * @param aType Message type to load
  680. * @param aTimestamp load based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
  681. * @param aCount Max number of messages to load. if aCount<0, will be handled as count=1
  682. * @param aUsername Message sender (optional). Use aUsername=nil to ignore
  683. * @param aDirection Message search direction
  684. EMMessageSearchDirectionUp: get aCount of messages before aMessageId;
  685. EMMessageSearchDirectionDown: get aCount of messages after aMessageId
  686. * @param aCompletionBlock The callback of completion block
  687. *
  688. */
  689. - (void)loadMessagesWithType:(EMMessageBodyType)aType
  690. timestamp:(long long)aTimestamp
  691. count:(int)aCount
  692. fromUser:(NSString*)aUsername
  693. searchDirection:(EMMessageSearchDirection)aDirection
  694. completion:(void (^)(NSArray *aMessages, EMError *aError))aCompletionBlock;
  695. /*!
  696. * \~chinese
  697. * 从数据库获取包含指定内容的消息,取到的消息按时间排序,如果参考的时间戳为负数,则从最新消息向前取,如果aCount小于等于0当作1处理
  698. *
  699. * @param aKeywords 搜索关键字,如果为空则忽略
  700. * @param aTimestamp 参考时间戳
  701. * @param aCount 获取的条数
  702. * @param aSender 消息发送方,如果为空则忽略
  703. * @param aDirection 消息搜索方向
  704. * @param aCompletionBlock 完成的回调
  705. *
  706. * \~english
  707. * Load messages with specified keyword from local database, returning messages are sorted by receiving timestamp based on EMMessageSearchDirection. If reference timestamp is negative, load from the latest messages; if message count is negative, will be handled as count=1
  708. *
  709. * @param aKeyword Search keyword. aKeyword=nil to ignore
  710. * @param aTimestamp load based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
  711. * @param aCount Max number of messages to load
  712. * @param aSender Message sender (optional). Pass nil to ignore
  713. * @param aDirection Message search direction
  714. EMMessageSearchDirectionUp: get aCount of messages before aMessageId;
  715. EMMessageSearchDirectionDown: get aCount of messages after aMessageId * ----
  716. * @param aCompletionBlock The callback of completion block
  717. *
  718. */
  719. - (void)loadMessagesWithKeyword:(NSString*)aKeywords
  720. timestamp:(long long)aTimestamp
  721. count:(int)aCount
  722. fromUser:(NSString*)aSender
  723. searchDirection:(EMMessageSearchDirection)aDirection
  724. completion:(void (^)(NSArray *aMessages, EMError *aError))aCompletionBlock;
  725. @end