暂无描述

IEMChatManager.h 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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 "EMChatManagerDelegate.h"
  16. #import "EMConversation.h"
  17. #import "EMMessage.h"
  18. #import "EMTextMessageBody.h"
  19. #import "EMLocationMessageBody.h"
  20. #import "EMCmdMessageBody.h"
  21. #import "EMFileMessageBody.h"
  22. #import "EMImageMessageBody.h"
  23. #import "EMVoiceMessageBody.h"
  24. #import "EMVideoMessageBody.h"
  25. @class EMError;
  26. /*!
  27. * \~chinese
  28. * 聊天相关操作
  29. *
  30. * \~english
  31. * Operations of chat
  32. */
  33. @protocol IEMChatManager <NSObject>
  34. @required
  35. #pragma mark - Delegate
  36. /*!
  37. * \~chinese
  38. * 添加回调代理
  39. *
  40. * @param aDelegate 要添加的代理
  41. * @param aQueue 执行代理方法的队列
  42. *
  43. * \~english
  44. * Add delegate
  45. *
  46. * @param aDelegate Delegate
  47. * @param aQueue The queue of call delegate method
  48. */
  49. - (void)addDelegate:(id<EMChatManagerDelegate>)aDelegate
  50. delegateQueue:(dispatch_queue_t)aQueue;
  51. /*!
  52. * \~chinese
  53. * 添加回调代理
  54. *
  55. * @param aDelegate 要添加的代理
  56. *
  57. * \~english
  58. * Add delegate
  59. *
  60. * @param aDelegate Delegate
  61. */
  62. - (void)addDelegate:(id<EMChatManagerDelegate>)aDelegate;
  63. /*!
  64. * \~chinese
  65. * 移除回调代理
  66. *
  67. * @param aDelegate 要移除的代理
  68. *
  69. * \~english
  70. * Remove delegate
  71. *
  72. * @param aDelegate Delegate
  73. */
  74. - (void)removeDelegate:(id<EMChatManagerDelegate>)aDelegate;
  75. #pragma mark - Conversation
  76. /*!
  77. * \~chinese
  78. * 获取所有会话,如果内存中不存在会从DB中加载
  79. *
  80. * @result 会话列表<EMConversation>
  81. *
  82. * \~english
  83. * Get all conversations, by loading conversations from DB if not exist in memory
  84. *
  85. * @result Conversation list<EMConversation>
  86. */
  87. - (NSArray *)getAllConversations;
  88. /*!
  89. * \~chinese
  90. * 获取一个会话
  91. *
  92. * @param aConversationId 会话ID
  93. * @param aType 会话类型
  94. * @param aIfCreate 如果不存在是否创建
  95. *
  96. * @result 会话对象
  97. *
  98. * \~english
  99. * Get a conversation
  100. *
  101. * @param aConversationId Conversation id
  102. * @param aType Conversation type
  103. * @param aIfCreate Whether create conversation if not exist
  104. *
  105. * @result Conversation
  106. */
  107. - (EMConversation *)getConversation:(NSString *)aConversationId
  108. type:(EMConversationType)aType
  109. createIfNotExist:(BOOL)aIfCreate;
  110. /*!
  111. * \~chinese
  112. * 删除会话
  113. *
  114. * @param aConversationId 会话ID
  115. * @param isDeleteMessages 是否删除会话中的消息
  116. * @param aCompletionBlock 完成的回调
  117. *
  118. * \~english
  119. * Delete a conversation
  120. *
  121. * @param aConversationId Conversation id
  122. * @param isDeleteMessages Whether delete messages
  123. * @param aCompletionBlock The callback block of completion
  124. *
  125. */
  126. - (void)deleteConversation:(NSString *)aConversationId
  127. isDeleteMessages:(BOOL)aIsDeleteMessages
  128. completion:(void (^)(NSString *aConversationId, EMError *aError))aCompletionBlock;
  129. /*!
  130. * \~chinese
  131. * 删除一组会话
  132. *
  133. * @param aConversations 会话列表<EMConversation>
  134. * @param aIsDeleteMessages 是否删除会话中的消息
  135. * @param aCompletionBlock 完成的回调
  136. *
  137. * \~english
  138. * Delete multiple conversations
  139. *
  140. * @param aConversations Conversation list<EMConversation>
  141. * @param aIsDeleteMessages Whether delete messages
  142. * @param aCompletionBlock The callback block of completion
  143. *
  144. */
  145. - (void)deleteConversations:(NSArray *)aConversations
  146. isDeleteMessages:(BOOL)aIsDeleteMessages
  147. completion:(void (^)(EMError *aError))aCompletionBlock;
  148. /*!
  149. * \~chinese
  150. * 导入一组会话到DB
  151. *
  152. * @param aConversations 会话列表<EMConversation>
  153. * @param aCompletionBlock 完成的回调
  154. *
  155. *
  156. * \~english
  157. * Import multiple conversations to DB
  158. *
  159. * @param aConversations Conversation list<EMConversation>
  160. * @param aCompletionBlock The callback block of completion
  161. *
  162. */
  163. - (void)importConversations:(NSArray *)aConversations
  164. completion:(void (^)(EMError *aError))aCompletionBlock;
  165. #pragma mark - Message
  166. /*!
  167. * \~chinese
  168. * 获取消息附件路径, 存在这个路径的文件,删除会话时会被删除
  169. *
  170. * @param aConversationId 会话ID
  171. *
  172. * @result 附件路径
  173. *
  174. * \~english
  175. * Get message attachment local path for the conversation. Delete the conversation will also delete the files under the file path.
  176. *
  177. * @param aConversationId Conversation id
  178. *
  179. * @result Attachment path
  180. */
  181. - (NSString *)getMessageAttachmentPath:(NSString *)aConversationId;
  182. /*!
  183. * \~chinese
  184. * 导入一组消息到DB
  185. *
  186. * @param aMessages 消息列表<EMMessage>
  187. * @param aCompletionBlock 完成的回调
  188. *
  189. * \~english
  190. * Import multiple messages
  191. *
  192. * @param aMessages Message list<EMMessage>
  193. * @param aCompletionBlock The callback block of completion
  194. *
  195. */
  196. - (void)importMessages:(NSArray *)aMessages
  197. completion:(void (^)(EMError *aError))aCompletionBlock;
  198. /*!
  199. * \~chinese
  200. * 更新消息到DB
  201. *
  202. * @param aMessage 消息
  203. * @param aCompletionBlock 完成的回调
  204. *
  205. * \~english
  206. * Update message
  207. *
  208. * @param aMessage Message
  209. * @param aSuccessBlock The callback block of completion
  210. *
  211. */
  212. - (void)updateMessage:(EMMessage *)aMessage
  213. completion:(void (^)(EMMessage *aMessage, EMError *aError))aCompletionBlock;
  214. /*!
  215. * \~chinese
  216. * 发送消息已读回执
  217. *
  218. * 异步方法
  219. *
  220. * @param aMessage 消息
  221. * @param aCompletionBlock 完成的回调
  222. *
  223. * \~english
  224. * Send read acknowledgement for message
  225. *
  226. *
  227. * @param aMessage Message instance
  228. * @param aCompletionBlock The callback block of completion
  229. *
  230. */
  231. - (void)sendMessageReadAck:(EMMessage *)aMessage
  232. completion:(void (^)(EMMessage *aMessage, EMError *aError))aCompletionBlock;
  233. /*!
  234. * \~chinese
  235. * 发送消息
  236. *
  237. * @param aMessage 消息
  238. * @param aProgressBlock 附件上传进度回调block
  239. * @param aCompletion 发送完成回调block
  240. *
  241. * \~english
  242. * Send a message
  243. *
  244. *
  245. * @param aMessage Message instance
  246. * @param aProgressBlock The block of attachment upload progress
  247. * @param aCompletion The block of send complete
  248. */
  249. - (void)sendMessage:(EMMessage *)aMessage
  250. progress:(void (^)(int progress))aProgressBlock
  251. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  252. /*!
  253. * \~chinese
  254. * 重发送消息
  255. *
  256. * @param aMessage 消息
  257. * @param aProgressBlock 附件上传进度回调block
  258. * @param aCompletion 发送完成回调block
  259. *
  260. * \~english
  261. * Resend Message
  262. *
  263. * @param aMessage Message instance
  264. * @param aProgressBlock The callback block of attachment upload progress
  265. * @param aCompletion The callback block of send complete
  266. */
  267. - (void)resendMessage:(EMMessage *)aMessage
  268. progress:(void (^)(int progress))aProgressBlock
  269. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  270. /*!
  271. * \~chinese
  272. * 下载缩略图(图片消息的缩略图或视频消息的第一帧图片),SDK会自动下载缩略图,所以除非自动下载失败,用户不需要自己下载缩略图
  273. *
  274. * @param aMessage 消息
  275. * @param aProgressBlock 附件下载进度回调block
  276. * @param aCompletion 下载完成回调block
  277. *
  278. * \~english
  279. * Download message thumbnail (thumbnail of image message or first frame of video image), SDK downloads thumbails automatically, no need to download thumbail manually unless automatic download failed.
  280. *
  281. * @param aMessage Message instance
  282. * @param aProgressBlock The callback block of attachment download progress
  283. * @param aCompletion The callback block of download complete
  284. */
  285. - (void)downloadMessageThumbnail:(EMMessage *)aMessage
  286. progress:(void (^)(int progress))aProgressBlock
  287. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  288. /*!
  289. * \~chinese
  290. * 下载消息附件(语音,视频,图片原图,文件),SDK会自动下载语音消息,所以除非自动下载语音失败,用户不需要自动下载语音附件
  291. *
  292. * 异步方法
  293. *
  294. * @param aMessage 消息
  295. * @param aProgressBlock 附件下载进度回调block
  296. * @param aCompletion 下载完成回调block
  297. *
  298. * \~english
  299. * Download message attachment(voice, video, image or file), SDK downloads attachment automatically, no need to download attachment manually unless automatic download failed
  300. *
  301. *
  302. * @param aMessage Message instance
  303. * @param aProgressBlock The callback block of attachment download progress
  304. * @param aCompletion The callback block of download complete
  305. */
  306. - (void)downloadMessageAttachment:(EMMessage *)aMessage
  307. progress:(void (^)(int progress))aProgressBlock
  308. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  309. #pragma mark - Deprecated methods
  310. /*!
  311. * \~chinese
  312. * 从数据库中获取所有的会话,执行后会更新内存中的会话列表
  313. *
  314. * 同步方法,会阻塞当前线程
  315. *
  316. * @result 会话列表<EMConversation>
  317. *
  318. * \~english
  319. * Load all conversations from DB, will update conversation list in memory after this method is called
  320. *
  321. * Synchronization method will block the current thread
  322. *
  323. * @result Conversation list<EMConversation>
  324. */
  325. - (NSArray *)loadAllConversationsFromDB __deprecated_msg("Use -getAllConversations");
  326. /*!
  327. * \~chinese
  328. * 删除会话
  329. *
  330. * @param aConversationId 会话ID
  331. * @param aDeleteMessage 是否删除会话中的消息
  332. *
  333. * @result 是否成功
  334. *
  335. * \~english
  336. * Delete a conversation
  337. *
  338. * @param aConversationId Conversation id
  339. * @param aDeleteMessage Whether delete messages
  340. *
  341. * @result Whether deleted successfully
  342. */
  343. - (BOOL)deleteConversation:(NSString *)aConversationId
  344. deleteMessages:(BOOL)aDeleteMessage __deprecated_msg("Use -deleteConversation:isDeleteMessages:completion:");
  345. /*!
  346. * \~chinese
  347. * 删除一组会话
  348. *
  349. * @param aConversations 会话列表<EMConversation>
  350. * @param aDeleteMessage 是否删除会话中的消息
  351. *
  352. * @result 是否成功
  353. *
  354. * \~english
  355. * Delete multiple conversations
  356. *
  357. * @param aConversations Conversation list<EMConversation>
  358. * @param aDeleteMessage Whether delete messages
  359. *
  360. * @result Whether deleted successfully
  361. */
  362. - (BOOL)deleteConversations:(NSArray *)aConversations
  363. deleteMessages:(BOOL)aDeleteMessage __deprecated_msg("Use -deleteConversations:isDeleteMessages:completion:");
  364. /*!
  365. * \~chinese
  366. * 导入一组会话到DB
  367. *
  368. * @param aConversations 会话列表<EMConversation>
  369. *
  370. * @result 是否成功
  371. *
  372. * \~english
  373. * Import multiple conversations to DB
  374. *
  375. * @param aConversations Conversation list<EMConversation>
  376. *
  377. * @result Whether imported successfully
  378. */
  379. - (BOOL)importConversations:(NSArray *)aConversations __deprecated_msg("Use -importConversations:completion:");
  380. /*!
  381. * \~chinese
  382. * 导入一组消息到DB
  383. *
  384. * @param aMessages 消息列表<EMMessage>
  385. *
  386. * @result 是否成功
  387. *
  388. * \~english
  389. * Import multiple messages
  390. *
  391. * @param aMessages Message list<EMMessage>
  392. *
  393. * @result Whether imported successfully
  394. */
  395. - (BOOL)importMessages:(NSArray *)aMessages __deprecated_msg("Use -importMessages:completion:");
  396. /*!
  397. * \~chinese
  398. * 更新消息到DB
  399. *
  400. * @param aMessage 消息
  401. *
  402. * @result 是否成功
  403. *
  404. * \~english
  405. * Update message to DB
  406. *
  407. * @param aMessage Message
  408. *
  409. * @result Whether updated successfully
  410. */
  411. - (BOOL)updateMessage:(EMMessage *)aMessage __deprecated_msg("Use -updateMessage:completion:");
  412. /*!
  413. * \~chinese
  414. * 发送消息已读回执
  415. *
  416. * 异步方法
  417. *
  418. * @param aMessage 消息
  419. *
  420. * \~english
  421. * Send read ack for message
  422. *
  423. * Asynchronous methods
  424. *
  425. * @param aMessage Message instance
  426. */
  427. - (void)asyncSendReadAckForMessage:(EMMessage *)aMessage __deprecated_msg("Use -sendMessageReadAck:completion:");
  428. /*!
  429. * \~chinese
  430. * 发送消息
  431. *
  432. * 异步方法
  433. *
  434. * @param aMessage 消息
  435. * @param aProgressCompletion 附件上传进度回调block
  436. * @param aCompletion 发送完成回调block
  437. *
  438. * \~english
  439. * Send a message
  440. *
  441. * Asynchronous methods
  442. *
  443. * @param aMessage Message instance
  444. * @param aProgressCompletion The block of attachment upload progress
  445. *
  446. * @param aCompletion The block of send complete
  447. */
  448. - (void)asyncSendMessage:(EMMessage *)aMessage
  449. progress:(void (^)(int progress))aProgressCompletion
  450. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -sendMessage:progress:completion:");
  451. /*!
  452. * \~chinese
  453. * 重发送消息
  454. *
  455. * 异步方法
  456. *
  457. * @param aMessage 消息
  458. * @param aProgressCompletion 附件上传进度回调block
  459. * @param aCompletion 发送完成回调block
  460. *
  461. * \~english
  462. * Resend Message
  463. *
  464. * Asynchronous methods
  465. *
  466. * @param aMessage Message instance
  467. * @param aProgressCompletion The callback block of attachment upload progress
  468. * @param aCompletion The callback block of send complete
  469. */
  470. - (void)asyncResendMessage:(EMMessage *)aMessage
  471. progress:(void (^)(int progress))aProgressCompletion
  472. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -resendMessage:progress:completion:");
  473. /*!
  474. * \~chinese
  475. * 下载缩略图(图片消息的缩略图或视频消息的第一帧图片),SDK会自动下载缩略图,所以除非自动下载失败,用户不需要自己下载缩略图
  476. *
  477. * 异步方法
  478. *
  479. * @param aMessage 消息
  480. * @param aProgressCompletion 附件下载进度回调block
  481. * @param aCompletion 下载完成回调block
  482. *
  483. * \~english
  484. * 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
  485. *
  486. * Asynchronous methods
  487. *
  488. * @param aMessage Message instance
  489. * @param aProgressCompletion The callback block of attachment download progress
  490. * @param aCompletion The callback block of download complete
  491. */
  492. - (void)asyncDownloadMessageThumbnail:(EMMessage *)aMessage
  493. progress:(void (^)(int progress))aProgressCompletion
  494. completion:(void (^)(EMMessage * message, EMError *error))aCompletion __deprecated_msg("Use -downloadMessageThumbnail:progress:completion:");
  495. /*!
  496. * \~chinese
  497. * 下载消息附件(语音,视频,图片原图,文件),SDK会自动下载语音消息,所以除非自动下载语音失败,用户不需要自动下载语音附件
  498. *
  499. * 异步方法
  500. *
  501. * @param aMessage 消息
  502. * @param aProgressCompletion 附件下载进度回调block
  503. * @param aCompletion 下载完成回调block
  504. *
  505. * \~english
  506. * Download message attachment(voice, video, image or file), SDK can download voice automatically, so user should NOT download voice manually except automatic download failed
  507. *
  508. * Asynchronous methods
  509. *
  510. * @param aMessage Message instance
  511. * @param aProgressCompletion The callback block of attachment download progress
  512. * @param aCompletion The callback block of download complete
  513. */
  514. - (void)asyncDownloadMessageAttachments:(EMMessage *)aMessage
  515. progress:(void (^)(int progress))aProgressCompletion
  516. completion:(void (^)(EMMessage *message, EMError *error))aCompletion __deprecated_msg("Use -downloadMessageAttachment:progress:completion");
  517. @end