IEMContactManager.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /*!
  2. * \~chinese
  3. * @header IEMContactManager.h
  4. * @abstract 此协议定义了好友相关操作
  5. * @author Hyphenate
  6. * @version 3.00
  7. *
  8. * \~english
  9. * @header IEMContactManager.h
  10. * @abstract The protocol defines the operations of contact
  11. * @author Hyphenate
  12. * @version 3.00
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "EMCommonDefs.h"
  16. #import "EMContactManagerDelegate.h"
  17. @class EMError;
  18. /*!
  19. * \~chinese
  20. * 好友相关操作
  21. *
  22. * \~english
  23. * Contact Management
  24. */
  25. @protocol IEMContactManager <NSObject>
  26. @required
  27. #pragma mark - Delegate
  28. /*!
  29. * \~chinese
  30. * 添加回调代理
  31. *
  32. * @param aDelegate 要添加的代理
  33. * @param aQueue 执行代理方法的队列
  34. *
  35. * \~english
  36. * Add delegate
  37. *
  38. * @param aDelegate Delegate
  39. * @param aQueue (optional) The queue of calling delegate methods. Pass in nil to run on main thread.
  40. */
  41. - (void)addDelegate:(id<EMContactManagerDelegate>)aDelegate
  42. delegateQueue:(dispatch_queue_t)aQueue;
  43. /*!
  44. * \~chinese
  45. * 移除回调代理
  46. *
  47. * @param aDelegate 要移除的代理
  48. *
  49. * \~english
  50. * Remove delegate
  51. *
  52. * @param aDelegate Delegate
  53. */
  54. - (void)removeDelegate:(id)aDelegate;
  55. #pragma mark - Contact Operations
  56. /*!
  57. * \~chinese
  58. * 获取本地存储的所有好友
  59. *
  60. * @result 好友列表<NSString>
  61. *
  62. * \~english
  63. * Get all contacts from local database
  64. *
  65. * @result Contact list<String>
  66. */
  67. - (NSArray *)getContacts;
  68. /*!
  69. * \~chinese
  70. * 从服务器获取所有的好友
  71. *
  72. * @param aCompletionBlock 完成的回调
  73. *
  74. * \~english
  75. * Get all contacts from the server
  76. *
  77. * @param aCompletionBlock The callback block of completion
  78. *
  79. */
  80. - (void)getContactsFromServerWithCompletion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  81. /*!
  82. * \~chinese
  83. * 从服务器获取所有的好友
  84. *
  85. * 同步方法,会阻塞当前线程
  86. *
  87. * @param pError 错误信息
  88. *
  89. * @return 好友列表<NSString>
  90. *
  91. * \~english
  92. * Get all the contacts from the server
  93. *
  94. * Synchronization method will block the current thread
  95. *
  96. * @param pError Error
  97. *
  98. * @return Contact list<NSString>
  99. */
  100. - (NSArray *)getContactsFromServerWithError:(EMError **)pError;
  101. /*!
  102. * \~chinese
  103. * 添加好友
  104. *
  105. * 同步方法,会阻塞当前线程
  106. *
  107. * @param aUsername 要添加的用户
  108. * @param aMessage 邀请信息
  109. *
  110. * @return 错误信息
  111. *
  112. * \~english
  113. * Add a contact with invitation message
  114. *
  115. * Synchronization method will block the current thread
  116. *
  117. * @param aUsername The user to add
  118. * @param aMessage (optional) Invitation message. Pass in nil to ignore.
  119. *
  120. * @return Error
  121. */
  122. - (EMError *)addContact:(NSString *)aUsername
  123. message:(NSString *)aMessage;
  124. /*!
  125. * \~chinese
  126. * 添加好友
  127. *
  128. * @param aUsername 要添加的用户
  129. * @param aMessage 邀请信息
  130. * @param aCompletionBlock 完成的回调
  131. *
  132. * \~english
  133. * Add a contact
  134. *
  135. * @param aUsername The user to be added
  136. * @param aMessage Friend request message
  137. * @param aCompletionBlock The callback block of completion
  138. *
  139. */
  140. - (void)addContact:(NSString *)aUsername
  141. message:(NSString *)aMessage
  142. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  143. /*!
  144. * \~chinese
  145. * 删除好友
  146. *
  147. * 同步方法,会阻塞当前线程
  148. *
  149. * @param aUsername 要删除的好友
  150. * @param aIsDeleteConversation 是否删除会话
  151. *
  152. * @return 错误信息
  153. *
  154. * \~english
  155. * Delete a contact
  156. *
  157. * Synchronization method will block the current thread
  158. *
  159. * @param aUsername The user to delete
  160. * @param aIsDeleteConversation If to keep the assoicated conversation and messages
  161. *
  162. * @return Error
  163. */
  164. - (EMError *)deleteContact:(NSString *)aUsername
  165. isDeleteConversation:(BOOL)aIsDeleteConversation;
  166. /*!
  167. * \~chinese
  168. * 删除好友
  169. *
  170. * @param aUsername 要删除的好友
  171. * @param aIsDeleteConversation 是否删除会话
  172. * @param aCompletionBlock 完成的回调
  173. *
  174. * \~english
  175. * Delete a contact
  176. *
  177. * @param aUsername The user to be deleted
  178. * @param aIsDeleteConversation Delete the conversation or not
  179. * @param aCompletionBlock The callback block of completion
  180. *
  181. */
  182. - (void)deleteContact:(NSString *)aUsername
  183. isDeleteConversation:(BOOL)aIsDeleteConversation
  184. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  185. /*!
  186. * \~chinese
  187. * 同意加好友的申请
  188. *
  189. * @param aUsername 申请者
  190. * @param aCompletionBlock 完成的回调
  191. *
  192. * \~english
  193. * Apporove a friend request
  194. *
  195. * @param aUsername User who initiated the friend request
  196. * @param aCompletionBlock The callback block of completion
  197. *
  198. */
  199. - (void)approveFriendRequestFromUser:(NSString *)aUsername
  200. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  201. /*!
  202. * \~chinese
  203. * 拒绝加好友的申请
  204. *
  205. * @param aUsername 申请者
  206. * @param aCompletionBlock 完成的回调
  207. *
  208. * \~english
  209. * Decline a friend request
  210. *
  211. * @param aUsername User who initiated the friend request
  212. * @param aCompletionBlock The callback block of completion
  213. *
  214. */
  215. - (void)declineFriendRequestFromUser:(NSString *)aUsername
  216. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  217. #pragma mark - Blacklist Operations
  218. /*!
  219. * \~chinese
  220. * 从本地获取黑名单列表
  221. *
  222. * @result 黑名单列表<NSString>
  223. *
  224. * \~english
  225. * Get the blacklist of blocked users from local database
  226. *
  227. * @result Blacklist<NSString> blacklist usernames
  228. */
  229. - (NSArray *)getBlackList;
  230. /*!
  231. * \~chinese
  232. * 从服务器获取黑名单列表
  233. *
  234. * @param aCompletionBlock 完成的回调
  235. *
  236. * \~english
  237. * Get the blacklist from the server
  238. *
  239. * @param aCompletionBlock The callback block of completion
  240. *
  241. * @result aList<NSString> blacklist usernames
  242. */
  243. - (void)getBlackListFromServerWithCompletion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  244. /*!
  245. * \~chinese
  246. * 从服务器获取黑名单列表
  247. *
  248. * 同步方法,会阻塞当前线程
  249. *
  250. * @param pError 错误信息
  251. *
  252. * @return 黑名单列表<NSString>
  253. *
  254. * \~english
  255. * Get the blacklist from the server
  256. *
  257. * Synchronization method will block the current thread
  258. *
  259. * @param pError Error
  260. *
  261. * @return Blacklist<NSString>
  262. */
  263. - (NSArray *)getBlackListFromServerWithError:(EMError **)pError;
  264. /*!
  265. * \~chinese
  266. * 将用户加入黑名单
  267. *
  268. * 同步方法,会阻塞当前线程
  269. *
  270. * @param aUsername 要加入黑命单的用户
  271. *
  272. * @return 错误信息
  273. *
  274. * \~english
  275. * Add a user to blacklist
  276. *
  277. * Synchronization method will block the current thread
  278. *
  279. * @param aUsername Block user
  280. *
  281. * @return Error
  282. */
  283. - (EMError *)addUserToBlackList:(NSString *)aUsername;
  284. /*!
  285. * \~chinese
  286. * 将用户加入黑名单
  287. *
  288. * @param aUsername 要加入黑命单的用户
  289. * @param aCompletionBlock 完成的回调
  290. *
  291. * \~english
  292. * Add a user to blacklist
  293. *
  294. * @param aUsername Block user
  295. * @param aCompletionBlock The callback block of completion
  296. *
  297. */
  298. - (void)addUserToBlackList:(NSString *)aUsername
  299. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  300. /*!
  301. * \~chinese
  302. * 将用户移出黑名单
  303. *
  304. * 同步方法,会阻塞当前线程
  305. *
  306. * @param aUsername 要移出黑命单的用户
  307. *
  308. * @return 错误信息
  309. *
  310. * \~english
  311. * Remove user out of blacklist
  312. *
  313. * Synchronization method will block the current thread
  314. *
  315. * @param aUsername Unblock user
  316. *
  317. * @return Error
  318. */
  319. - (EMError *)removeUserFromBlackList:(NSString *)aUsername;
  320. /*!
  321. * \~chinese
  322. * 将用户移出黑名单
  323. *
  324. * @param aUsername 要移出黑命单的用户
  325. * @param aCompletionBlock 完成的回调
  326. *
  327. * \~english
  328. * Remove a user from blacklist
  329. *
  330. * @param aUsername Unblock user
  331. * @param aCompletionBlock The callback block of completion
  332. *
  333. */
  334. - (void)removeUserFromBlackList:(NSString *)aUsername
  335. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  336. /*!
  337. * \~chinese
  338. * 同意加好友的申请
  339. *
  340. * 同步方法,会阻塞当前线程
  341. *
  342. * @param aUsername 申请者
  343. *
  344. * @return 错误信息
  345. *
  346. * \~english
  347. * Accept a friend request
  348. *
  349. * Synchronization method will block the current thread
  350. *
  351. * @param aUsername User who initiated the friend request
  352. *
  353. * @return Error
  354. */
  355. - (EMError *)acceptInvitationForUsername:(NSString *)aUsername;
  356. /*!
  357. * \~chinese
  358. * 拒绝加好友的申请
  359. *
  360. * 同步方法,会阻塞当前线程
  361. *
  362. * @param aUsername 申请者
  363. *
  364. * @return 错误信息
  365. *
  366. * \~english
  367. * Decline a friend request
  368. *
  369. * Synchronization method will block the current thread
  370. *
  371. * @param aUsername User who initiated the friend request
  372. *
  373. * @return Error
  374. *
  375. * Please use the new method
  376. * - (void)declineFriendRequestFromUser:(NSString *)aUsername
  377. * completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  378. */
  379. - (EMError *)declineInvitationForUsername:(NSString *)aUsername;
  380. #pragma mark - Other platform
  381. /*!
  382. * \~chinese
  383. * 获取当前账号在其他平台(Windows或者Web)登录的id列表
  384. * id使用方法类似于好友username
  385. *
  386. * @param pError 错误信息
  387. *
  388. * @return id列表
  389. *
  390. * \~english
  391. * Get the id list of the current account on another platform (Windows or Web)
  392. * Id usage is similar to friend username
  393. *
  394. * @param pError Error
  395. *
  396. * @return id list
  397. *
  398. */
  399. - (NSArray *)getSelfIdsOnOtherPlatformWithError:(EMError **)pError;
  400. /*!
  401. * \~chinese
  402. * 获取当前账号在其他平台(Windows或者Web)登录的id列表
  403. * id使用方法类似于好友username
  404. *
  405. * @param aCompletionBlock 完成的回调
  406. *
  407. * \~english
  408. * Get the id list of the current account on another platform (Windows or Web)
  409. * Id usage is similar to friend username
  410. *
  411. * @param aCompletionBlock The callback block of completion
  412. *
  413. */
  414. - (void)getSelfIdsOnOtherPlatformWithCompletion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  415. #pragma mark - EM_DEPRECATED_IOS
  416. /*!
  417. * \~chinese
  418. * 将用户加入黑名单
  419. *
  420. * 同步方法,会阻塞当前线程
  421. *
  422. * @param aUsername 要加入黑命单的用户
  423. * @param aBoth 是否同时屏蔽发给对方的消息
  424. *
  425. * @return 错误信息
  426. *
  427. * \~english
  428. * Add a user to blacklist
  429. *
  430. * Synchronization method will block the current thread
  431. *
  432. * @param aUsername Block user
  433. * @param aBoth if aBoth is YES, then hide user and block messages from blocked user; if NO, then hide user from blocked user
  434. *
  435. * @return Error
  436. */
  437. - (EMError *)addUserToBlackList:(NSString *)aUsername
  438. relationshipBoth:(BOOL)aBoth EM_DEPRECATED_IOS(3_2_3, 3_6_2, "Use -[IEMContactManager addUserToBlackList:]");
  439. #pragma mark - EM_DEPRECATED_IOS 3.2.3
  440. /*!
  441. * \~chinese
  442. * 添加回调代理
  443. *
  444. * @param aDelegate 要添加的代理
  445. *
  446. * \~english
  447. * Add delegate
  448. *
  449. * @param aDelegate Delegate
  450. */
  451. - (void)addDelegate:(id<EMContactManagerDelegate>)aDelegate EM_DEPRECATED_IOS(3_1_0, 3_2_2, "Use -[IEMContactManager addDelegate:delegateQueue:]");
  452. #pragma mark - EM_DEPRECATED_IOS < 3.2.3
  453. /*!
  454. * \~chinese
  455. * 从数据库获取所有的好友
  456. *
  457. * @return 好友列表<NSString>
  458. *
  459. * \~english
  460. * Get all the friends from the DB
  461. *
  462. * @return Contact list<NSString>
  463. */
  464. - (NSArray *)getContactsFromDB __deprecated_msg("Use -getContacts");
  465. /*!
  466. * \~chinese
  467. * 从数据库获取黑名单列表
  468. *
  469. * @return 黑名单列表<NSString>
  470. *
  471. * \~english
  472. * Get the blacklist from the DB
  473. *
  474. * @return Blacklist<NSString>
  475. */
  476. - (NSArray *)getBlackListFromDB __deprecated_msg("Use -getBlackList");
  477. /*!
  478. * \~chinese
  479. * 从服务器获取所有的好友
  480. *
  481. * @param aSuccessBlock 成功的回调
  482. * @param aFailureBlock 失败的回调
  483. *
  484. * \~english
  485. * Get all the friends from the server
  486. *
  487. * @param aSuccessBlock The callback block of success
  488. * @param aFailureBlock The callback block of failure
  489. *
  490. */
  491. - (void)asyncGetContactsFromServer:(void (^)(NSArray *aList))aSuccessBlock
  492. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -getContactsFromServerWithCompletion:");
  493. /*!
  494. * \~chinese
  495. * 添加好友
  496. *
  497. * @param aUsername 要添加的用户
  498. * @param aMessage 邀请信息
  499. * @param aSuccessBlock 成功的回调
  500. * @param aFailureBlock 失败的回调
  501. *
  502. * \~english
  503. * Add a contact
  504. *
  505. * @param aUsername The user to add
  506. * @param aMessage Friend invitation message
  507. * @param aSuccessBlock The callback block of success
  508. * @param aFailureBlock The callback block of failure
  509. *
  510. */
  511. - (void)asyncAddContact:(NSString *)aUsername
  512. message:(NSString *)aMessage
  513. success:(void (^)())aSuccessBlock
  514. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -addContact:message:completion:");
  515. /*!
  516. * \~chinese
  517. * 删除好友
  518. *
  519. * 同步方法,会阻塞当前线程
  520. *
  521. * @param aUsername 要删除的好友
  522. *
  523. * @return 错误信息
  524. *
  525. * \~english
  526. * Delete a contact
  527. *
  528. * Synchronization method will block the current thread
  529. *
  530. * @param aUsername The user to delete
  531. *
  532. * @return Error
  533. */
  534. - (EMError *)deleteContact:(NSString *)aUsername __deprecated_msg("Use -deleteContact:username:isDeleteConversation:");
  535. /*!
  536. * \~chinese
  537. * 删除好友
  538. *
  539. * @param aUsername 要删除的好友
  540. * @param aCompletionBlock 完成的回调
  541. *
  542. * \~english
  543. * Delete a contact
  544. *
  545. * @param aUsername The user to be deleted
  546. * @param aCompletionBlock The callback block of completion
  547. *
  548. */
  549. - (void)deleteContact:(NSString *)aUsername
  550. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock __deprecated_msg("Use -deleteContact:username:isDeleteConversation:");
  551. /*!
  552. * \~chinese
  553. * 删除好友
  554. *
  555. * @param aUsername 要删除的好友
  556. * @param aSuccessBlock 成功的回调
  557. * @param aFailureBlock 失败的回调
  558. *
  559. * \~english
  560. * Delete friend
  561. *
  562. * @param aUsername The user to delete
  563. * @param aSuccessBlock The callback block of success
  564. * @param aFailureBlock The callback block of failure
  565. *
  566. */
  567. - (void)asyncDeleteContact:(NSString *)aUsername
  568. success:(void (^)())aSuccessBlock
  569. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -deleteContact:completion:");
  570. /*!
  571. * \~chinese
  572. * 从服务器获取黑名单列表
  573. *
  574. * @param aSuccessBlock 成功的回调
  575. * @param aFailureBlock 失败的回调
  576. *
  577. * \~english
  578. * Get the blacklist from the server
  579. *
  580. * @param aSuccessBlock The callback block of success
  581. * @param aFailureBlock The callback block of failure
  582. *
  583. */
  584. - (void)asyncGetBlackListFromServer:(void (^)(NSArray *aList))aSuccessBlock
  585. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -getBlackListFromServerWithCompletion:");
  586. /*!
  587. * \~chinese
  588. * 将用户加入黑名单
  589. *
  590. * @param aUsername 要加入黑命单的用户
  591. * @param aBoth 是否同时屏蔽发给对方的消息
  592. * @param aSuccessBlock 成功的回调
  593. * @param aFailureBlock 失败的回调
  594. *
  595. * \~english
  596. * Add user to blacklist
  597. *
  598. * @param aUsername The user to add
  599. * @param aBoth Whether block messages from me to the user which is added to the black list
  600. * @param aSuccessBlock The callback block of success
  601. * @param aFailureBlock The callback block of failure
  602. *
  603. */
  604. - (void)asyncAddUserToBlackList:(NSString *)aUsername
  605. relationshipBoth:(BOOL)aBoth
  606. success:(void (^)())aSuccessBlock
  607. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -addUserToBlackList:completion:");
  608. /*!
  609. * \~chinese
  610. * 将用户移出黑名单
  611. *
  612. * @param aUsername 要移出黑命单的用户
  613. * @param aSuccessBlock 成功的回调
  614. * @param aFailureBlock 失败的回调
  615. *
  616. * \~english
  617. * Remove user from blacklist
  618. *
  619. * @param aUsername The user to remove from blacklist
  620. * @param aSuccessBlock The callback block of success
  621. * @param aFailureBlock The callback block of failure
  622. *
  623. */
  624. - (void)asyncRemoveUserFromBlackList:(NSString *)aUsername
  625. success:(void (^)())aSuccessBlock
  626. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -removeUserFromBlackList:completion:");
  627. /*!
  628. * \~chinese
  629. * 同意加好友的申请
  630. *
  631. * @param aUsername 申请者
  632. * @param aSuccessBlock 成功的回调
  633. * @param aFailureBlock 失败的回调
  634. *
  635. * \~english
  636. * Agree invitation
  637. *
  638. * @param aUsername Applicants
  639. * @param aSuccessBlock The callback block of success
  640. * @param aFailureBlock The callback block of failure
  641. *
  642. */
  643. - (void)asyncAcceptInvitationForUsername:(NSString *)aUsername
  644. success:(void (^)())aSuccessBlock
  645. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -approveFriendRequestFromUser:completion:");
  646. /*!
  647. * \~chinese
  648. * 拒绝加好友的申请
  649. *
  650. * @param aUsername 申请者
  651. * @param aSuccessBlock 成功的回调
  652. * @param aFailureBlock 失败的回调
  653. *
  654. * \~english
  655. * Decline invitation
  656. *
  657. * @param aUsername Applicants
  658. * @param aSuccessBlock The callback block of success
  659. * @param aFailureBlock The callback block of failure
  660. *
  661. */
  662. - (void)asyncDeclineInvitationForUsername:(NSString *)aUsername
  663. success:(void (^)())aSuccessBlock
  664. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -declineFriendRequestFromUser:completion:");
  665. @end