IEMChatManager.h 25 KB

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