EMClient.h 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. /*!
  2. * @header EMClient.h
  3. * @abstract SDK Client
  4. * @author Hyphenate
  5. * @version 3.00
  6. */
  7. #import <Foundation/Foundation.h>
  8. #import "EMClientDelegate.h"
  9. #import "EMMultiDevicesDelegate.h"
  10. #import "EMOptions.h"
  11. #import "EMPushOptions.h"
  12. #import "EMError.h"
  13. #import "IEMChatManager.h"
  14. #import "IEMContactManager.h"
  15. #import "IEMGroupManager.h"
  16. #import "IEMChatroomManager.h"
  17. #import "EMDeviceConfig.h"
  18. /*!
  19. * \~chinese
  20. * 服务检查类型
  21. *
  22. * \~english
  23. * Type of server check
  24. */
  25. typedef enum {
  26. EMServerCheckAccountValidation = 0, /*! \~chinese 账号检查 \~english Valid account */
  27. EMServerCheckGetDNSListFromServer, /*! \~chinese 获取服务列表检查 \~english Check get dns from server */
  28. EMServerCheckGetTokenFromServer, /*! \~chinese 获取token检查 \~english Check get token from server */
  29. EMServerCheckDoLogin, /*! \~chinese 登录检查 \~english Check login mode */
  30. EMServerCheckDoLogout, /*! \~chinese 登出检查 \~english Check logout mode */
  31. } EMServerCheckType;
  32. /*!
  33. * SDK Client
  34. */
  35. @interface EMClient : NSObject
  36. {
  37. EMPushOptions *_pushOptions;
  38. }
  39. /*!
  40. * \~chinese
  41. * SDK版本号
  42. *
  43. * \~english
  44. * SDK version
  45. */
  46. @property (nonatomic, strong, readonly) NSString *version;
  47. /*!
  48. * \~chinese
  49. * 当前登录账号
  50. *
  51. * \~english
  52. * Current logged in user's username
  53. */
  54. @property (nonatomic, strong, readonly) NSString *currentUsername;
  55. /*!
  56. * \~chinese
  57. * SDK属性
  58. *
  59. * \~english
  60. * SDK setting options
  61. */
  62. @property (nonatomic, strong, readonly) EMOptions *options;
  63. /*!
  64. * \~chinese
  65. * 推送设置
  66. *
  67. * \~english
  68. * Apple Push Notification Service setting
  69. */
  70. @property (nonatomic, strong, readonly) EMPushOptions *pushOptions;
  71. /*!
  72. * \~chinese
  73. * 聊天模块
  74. *
  75. * \~english
  76. * Chat Management
  77. */
  78. @property (nonatomic, strong, readonly) id<IEMChatManager> chatManager;
  79. /*!
  80. * \~chinese
  81. * 好友模块
  82. *
  83. * \~english
  84. * Contact Management
  85. */
  86. @property (nonatomic, strong, readonly) id<IEMContactManager> contactManager;
  87. /*!
  88. * \~chinese
  89. * 群组模块
  90. *
  91. * \~english
  92. * Group Management
  93. */
  94. @property (nonatomic, strong, readonly) id<IEMGroupManager> groupManager;
  95. /*!
  96. * \~chinese
  97. * 聊天室模块
  98. *
  99. * \~english
  100. * Chat Room Management
  101. */
  102. @property (nonatomic, strong, readonly) id<IEMChatroomManager> roomManager;
  103. /*!
  104. * \~chinese
  105. * SDK是否自动登录上次登录的账号
  106. *
  107. * \~english
  108. * If SDK will automatically log into with previously logged in session. If the current login failed, then isAutoLogin attribute will be reset to NO, you need to set it back to YES in order to allow automatic login
  109. * 1. password changed
  110. * 2. deactivate, forced logout, etc
  111. */
  112. @property (nonatomic, readonly) BOOL isAutoLogin;
  113. /*!
  114. * \~chinese
  115. * 用户是否已登录
  116. *
  117. * \~english
  118. * If a user logged in
  119. */
  120. @property (nonatomic, readonly) BOOL isLoggedIn;
  121. /*!
  122. * \~chinese
  123. * 是否连上聊天服务器
  124. *
  125. * \~english
  126. * Connection status to Hyphenate IM server
  127. */
  128. @property (nonatomic, readonly) BOOL isConnected;
  129. /*!
  130. * \~chinese
  131. * 获取SDK实例
  132. *
  133. * \~english
  134. * Get SDK singleton instance
  135. */
  136. + (instancetype)sharedClient;
  137. #pragma mark - Delegate
  138. /*!
  139. * \~chinese
  140. * 添加回调代理
  141. *
  142. * @param aDelegate 要添加的代理
  143. * @param aQueue 执行代理方法的队列
  144. *
  145. * \~english
  146. * Add delegate
  147. *
  148. * @param aDelegate Delegate
  149. * @param aQueue (optional) The queue of calling delegate methods. Pass in nil to run on main thread.
  150. */
  151. - (void)addDelegate:(id<EMClientDelegate>)aDelegate
  152. delegateQueue:(dispatch_queue_t)aQueue;
  153. /*!
  154. * \~chinese
  155. * 移除回调代理
  156. *
  157. * @param aDelegate 要移除的代理
  158. *
  159. * \~english
  160. * Remove delegate
  161. *
  162. * @param aDelegate Delegate
  163. */
  164. - (void)removeDelegate:(id)aDelegate;
  165. /*!
  166. * \~chinese
  167. * 注册多设备回调代理
  168. *
  169. * @param aDelegate 要添加的代理
  170. * @param aQueue 执行代理方法的队列
  171. *
  172. * \~english
  173. * Add multi-device delegate
  174. *
  175. * @param aDelegate Delegate
  176. * @param aQueue The queue of calling delegate methods
  177. */
  178. - (void)addMultiDevicesDelegate:(id<EMMultiDevicesDelegate>)aDelegate
  179. delegateQueue:(dispatch_queue_t)aQueue;
  180. /*!
  181. * \~chinese
  182. * 移除多设备回调代理
  183. *
  184. * @param aDelegate 要移除的代理
  185. *
  186. * \~english
  187. * Remove multi devices delegate
  188. *
  189. * @param aDelegate Delegate
  190. */
  191. - (void)removeMultiDevicesDelegate:(id<EMMultiDevicesDelegate>)aDelegate;
  192. #pragma mark - Initialize SDK
  193. /*!
  194. * \~chinese
  195. * 初始化sdk
  196. *
  197. * @param aOptions SDK配置项
  198. *
  199. * @result 错误信息
  200. *
  201. * \~english
  202. * Initialize the SDK
  203. *
  204. * @param aOptions SDK setting options
  205. *
  206. * @result Error
  207. */
  208. - (EMError *)initializeSDKWithOptions:(EMOptions *)aOptions;
  209. #pragma mark - Change AppKey
  210. /*!
  211. * \~chinese
  212. * 修改appkey,注意只有在未登录状态才能修改appkey
  213. *
  214. * @param aAppkey appkey
  215. *
  216. * @result 错误信息
  217. *
  218. * \~english
  219. * Change appkey. Can only change appkey when the user is logged out
  220. *
  221. * @param aAppkey appkey
  222. *
  223. * @result Error
  224. */
  225. - (EMError *)changeAppkey:(NSString *)aAppkey;
  226. #pragma mark - User Registeration
  227. /*!
  228. * \~chinese
  229. * 注册用户
  230. *
  231. * 同步方法,会阻塞当前线程. 不推荐使用,建议后台通过REST注册
  232. *
  233. * @param aUsername 用户名
  234. * @param aPassword 密码
  235. *
  236. * @result 错误信息
  237. *
  238. * \~english
  239. * Register a new IM user
  240. *
  241. * To ensure good reliability, registering new IM user via REST API from developer backend is highly recommended
  242. *
  243. * @param aUsername Username
  244. * @param aPassword Password
  245. *
  246. * @result Error
  247. */
  248. - (EMError *)registerWithUsername:(NSString *)aUsername
  249. password:(NSString *)aPassword;
  250. /*!
  251. * \~chinese
  252. * 注册用户
  253. *
  254. * 不推荐使用,建议后台通过REST注册
  255. *
  256. * @param aUsername 用户名
  257. * @param aPassword 密码
  258. * @param aCompletionBlock 完成的回调
  259. *
  260. * \~english
  261. * Register a new IM user
  262. *
  263. * To ensure good reliability, registering new IM user via REST API from developer backend is highly recommended
  264. *
  265. * @param aUsername Username
  266. * @param aPassword Password
  267. * @param aCompletionBlock The callback of completion block
  268. *
  269. */
  270. - (void)registerWithUsername:(NSString *)aUsername
  271. password:(NSString *)aPassword
  272. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  273. #pragma mark - Login
  274. /*!
  275. * \~chinese
  276. * 从服务器获取token
  277. *
  278. * @param aUsername 用户名
  279. * @param aPassword 密码
  280. * @param aCompletionBlock 完成的回调
  281. *
  282. * \~english
  283. * Get the token from the server
  284. *
  285. * @param aUsername Username
  286. * @param aPassword Password
  287. * @param aCompletionBlock The callback of completion block
  288. *
  289. */
  290. - (void)fetchTokenWithUsername:(NSString *)aUsername
  291. password:(NSString *)aPassword
  292. completion:(void (^)(NSString *aToken, EMError *aError))aCompletionBlock;
  293. /*!
  294. * \~chinese
  295. * 密码登录
  296. *
  297. * 同步方法,会阻塞当前线程
  298. *
  299. * @param aUsername 用户名
  300. * @param aPassword 密码
  301. *
  302. * @result 错误信息
  303. *
  304. * \~english
  305. * Login with password
  306. *
  307. * Synchronization method will block the current thread
  308. *
  309. * @param aUsername Username
  310. * @param aPassword Password
  311. *
  312. * @result Error
  313. */
  314. - (EMError *)loginWithUsername:(NSString *)aUsername
  315. password:(NSString *)aPassword;
  316. /*!
  317. * \~chinese
  318. * 密码登录
  319. *
  320. * @param aUsername 用户名
  321. * @param aPassword 密码
  322. * @param aCompletionBlock 完成的回调
  323. *
  324. * \~english
  325. * Login with password
  326. *
  327. * @param aUsername Username
  328. * @param aPassword Password
  329. * @param aCompletionBlock The callback of completion block
  330. *
  331. */
  332. - (void)loginWithUsername:(NSString *)aUsername
  333. password:(NSString *)aPassword
  334. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  335. /*!
  336. * \~chinese
  337. * token登录,不支持自动登录
  338. *
  339. * 同步方法,会阻塞当前线程
  340. *
  341. * @param aUsername 用户名
  342. * @param aToken Token
  343. *
  344. * @result 错误信息
  345. *
  346. * \~english
  347. * Login with token. Does not support automatic login
  348. *
  349. * Synchronization method will block the current thread
  350. *
  351. * @param aUsername Username
  352. * @param aToken Token
  353. *
  354. * @result Error
  355. */
  356. - (EMError *)loginWithUsername:(NSString *)aUsername
  357. token:(NSString *)aToken;
  358. /*!
  359. * \~chinese
  360. * token登录,不支持自动登录
  361. *
  362. * @param aUsername 用户名
  363. * @param aToken Token
  364. * @param aCompletionBlock 完成的回调
  365. *
  366. * \~english
  367. * Login with token. Does not support automatic login
  368. *
  369. * @param aUsername Username
  370. * @param aToken Token
  371. * @param aCompletionBlock The callback of completion block
  372. *
  373. */
  374. - (void)loginWithUsername:(NSString *)aUsername
  375. token:(NSString *)aToken
  376. completion:(void (^)(NSString *aUsername, EMError *aError))aCompletionBlock;
  377. #pragma mark - Logout
  378. /*!
  379. * \~chinese
  380. * 退出
  381. *
  382. * 同步方法,会阻塞当前线程
  383. *
  384. * @param aIsUnbindDeviceToken 是否解除device token的绑定,解除绑定后设备不会再收到消息推送
  385. * 如果传入YES, 解除绑定失败,将返回error
  386. *
  387. * @result 错误信息
  388. *
  389. * \~english
  390. * Logout
  391. *
  392. * Synchronization method will block the current thread
  393. *
  394. * @param aIsUnbindDeviceToken Unbind device token to disable Apple Push Notification Service
  395. *
  396. * @result Error
  397. */
  398. - (EMError *)logout:(BOOL)aIsUnbindDeviceToken;
  399. /*!
  400. * \~chinese
  401. * 退出
  402. *
  403. * @param aIsUnbindDeviceToken 是否解除device token的绑定,解除绑定后设备不会再收到消息推送
  404. * 如果传入YES, 解除绑定失败,将返回error
  405. * @param aCompletionBlock 完成的回调
  406. *
  407. * \~english
  408. * Logout
  409. *
  410. * @param aIsUnbindDeviceToken Unbind device token to disable the Apple Push Notification Service
  411. * @param aCompletionBlock The callback of completion block
  412. *
  413. */
  414. - (void)logout:(BOOL)aIsUnbindDeviceToken
  415. completion:(void (^)(EMError *aError))aCompletionBlock;
  416. #pragma mark - APNs
  417. /*!
  418. * \~chinese
  419. * 绑定device token
  420. *
  421. * 同步方法,会阻塞当前线程
  422. *
  423. * @param aDeviceToken 要绑定的token
  424. *
  425. * @result 错误信息
  426. *
  427. * \~english
  428. * Device token binding is required to enable Apple Push Notification Service
  429. *
  430. * Synchronization method will block the current thread
  431. *
  432. * @param aDeviceToken Device token to bind
  433. *
  434. * @result Error
  435. */
  436. - (EMError *)bindDeviceToken:(NSData *)aDeviceToken;
  437. /*!
  438. * \~chinese
  439. * 绑定device token
  440. *
  441. * @param aDeviceToken 要绑定的token
  442. * @param aCompletionBlock 完成的回调
  443. *
  444. * \~english
  445. * Device token binding is required to enable Apple push notification service
  446. *
  447. * @param aDeviceToken Device token to bind
  448. * @param aCompletionBlock The callback block of completion
  449. */
  450. - (void)registerForRemoteNotificationsWithDeviceToken:(NSData *)aDeviceToken
  451. completion:(void (^)(EMError *aError))aCompletionBlock;
  452. /*!
  453. * \~chinese
  454. * 设置推送消息显示的昵称
  455. *
  456. * 同步方法,会阻塞当前线程
  457. *
  458. * @param aNickname 要设置的昵称
  459. *
  460. * @result 错误信息
  461. *
  462. * \~english
  463. * Set display name for Apple Push Notification message
  464. *
  465. * Synchronization method will block the current thread
  466. *
  467. * @param aNickname Display name
  468. *
  469. * @result Error
  470. */
  471. - (EMError *)setApnsNickname:(NSString *)aNickname;
  472. /*!
  473. * \~chinese
  474. * 设置推送的显示名
  475. *
  476. * @param aDisplayName 推送显示名
  477. * @param aCompletionBlock 完成的回调
  478. *
  479. * \~english
  480. * Set display name for the push notification
  481. *
  482. * @param aDisplayName Display name of push
  483. * @param aCompletionBlock The callback block of completion
  484. *
  485. */
  486. - (void)updatePushNotifiationDisplayName:(NSString *)aDisplayName
  487. completion:(void (^)(NSString *aDisplayName, EMError *aError))aCompletionBlock;
  488. /*!
  489. * \~chinese
  490. * 从服务器获取推送属性
  491. *
  492. * 同步方法,会阻塞当前线程
  493. *
  494. * @param pError 错误信息
  495. *
  496. * @result 推送属性
  497. *
  498. * \~english
  499. * Get Apple Push Notification Service options from the server
  500. *
  501. * Synchronization method will block the current thread
  502. *
  503. * @param pError Error
  504. *
  505. * @result Apple Push Notification Service options
  506. */
  507. - (EMPushOptions *)getPushOptionsFromServerWithError:(EMError **)pError;
  508. /*!
  509. * \~chinese
  510. * 从服务器获取推送属性
  511. *
  512. * @param aCompletionBlock 完成的回调
  513. *
  514. * \~english
  515. * Get Apple Push Notification Service options from the server
  516. *
  517. * @param aCompletionBlock The callback of completion block
  518. */
  519. - (void)getPushNotificationOptionsFromServerWithCompletion:(void (^)(EMPushOptions *aOptions, EMError *aError))aCompletionBlock;
  520. /*!
  521. * \~chinese
  522. * 更新推送设置到服务器
  523. *
  524. * 同步方法,会阻塞当前线程
  525. *
  526. * @result 错误信息
  527. *
  528. * \~english
  529. * Update Apple Push Notification Service options to the server
  530. *
  531. * Synchronization method will block the current thread
  532. *
  533. * @result Error
  534. */
  535. - (EMError *)updatePushOptionsToServer;
  536. /*!
  537. * \~chinese
  538. * 更新推送设置到服务器
  539. *
  540. * @param aCompletionBlock 完成的回调
  541. *
  542. * \~english
  543. * Update Apple Push Notification Service options to the server
  544. *
  545. * @param aCompletionBlock The callback block of completion
  546. */
  547. - (void)updatePushNotificationOptionsToServerWithCompletion:(void (^)(EMError *aError))aCompletionBlock;
  548. #pragma mark - Log
  549. /*!
  550. * \~chinese
  551. * 上传日志到服务器
  552. *
  553. * 同步方法,会阻塞当前线程
  554. *
  555. * @result 错误信息
  556. *
  557. * \~english
  558. * Upload debugging log to server
  559. *
  560. * Synchronization method will block the current thread
  561. *
  562. * @result Error
  563. */
  564. - (EMError *)uploadLogToServer;
  565. /*!
  566. * \~chinese
  567. * 上传日志到服务器
  568. *
  569. * @param aCompletionBlock 完成的回调
  570. *
  571. * \~english
  572. * Upload debugging log to server
  573. *
  574. * @param aCompletionBlock The callback of completion block
  575. */
  576. - (void)uploadDebugLogToServerWithCompletion:(void (^)(EMError *aError))aCompletionBlock;
  577. /*!
  578. * \~chinese
  579. * 将日志文件压缩成.gz文件,返回gz文件路径。强烈建议方法完成之后删除该压缩文件
  580. *
  581. * 同步方法,会阻塞当前线程
  582. *
  583. * @param pError 错误信息
  584. *
  585. * @result 文件路径
  586. *
  587. * \~english
  588. * Compress the log file into a .gz file and return the gz file path. Recommend delete the gz file if file is no longer used
  589. *
  590. * Synchronization method will block the current thread
  591. *
  592. * @param pError Error
  593. *
  594. * @result File path
  595. */
  596. - (NSString *)getLogFilesPath:(EMError **)pError;
  597. /*!
  598. * \~chinese
  599. * 将日志文件压缩成.gz文件,返回gz文件路径。强烈建议方法完成之后删除该压缩文件
  600. *
  601. * @param aCompletionBlock 完成的回调
  602. *
  603. * \~english
  604. * Compress the log file into a .gz file and return the gz file path. Recommend delete the gz file if file is no longer used
  605. *
  606. * @param aCompletionBlock The callback of completion block
  607. */
  608. - (void)getLogFilesPathWithCompletion:(void (^)(NSString *aPath, EMError *aError))aCompletionBlock;
  609. #pragma mark - Multi Devices
  610. /*!
  611. * \~chinese
  612. * 从服务器获取所有已经登录的设备信息
  613. *
  614. * 同步方法,会阻塞当前线程
  615. *
  616. * @param aUsername 用户名
  617. * @param aPassword 密码
  618. * @param pError 错误信息
  619. *
  620. * @result 所有已经登录的设备信息<EMDeviceConfig>
  621. *
  622. * \~english
  623. * Get all the device information <EMDeviceConfig> that logged in to the server
  624. *
  625. * Synchronization method will block the current thread
  626. *
  627. * @param aUsername Username
  628. * @param aPassword Password
  629. * @param pError Error
  630. *
  631. * @result Information of logged in device <EMDeviceConfig>
  632. */
  633. - (NSArray *)getLoggedInDevicesFromServerWithUsername:(NSString *)aUsername
  634. password:(NSString *)aPassword
  635. error:(EMError **)pError;
  636. /*!
  637. * \~chinese
  638. * 从服务器获取所有已经登录的设备信息
  639. *
  640. * @param aUsername 用户名
  641. * @param aPassword 密码
  642. * @param aCompletionBlock 完成的回调
  643. *
  644. * \~english
  645. * Get all the device information <EMDeviceConfig> that logged in to the server
  646. *
  647. * @param aUsername Username
  648. * @param aPassword Password
  649. * @param aCompletionBlock The callback block of completion
  650. *
  651. * @result aList Information of logged in device <EMDeviceConfig>
  652. */
  653. - (void)getLoggedInDevicesFromServerWithUsername:(NSString *)aUsername
  654. password:(NSString *)aPassword
  655. completion:(void (^)(NSArray *aList, EMError *aError))aCompletionBlock;
  656. /*!
  657. * \~chinese
  658. * 强制指定的设备退出
  659. *
  660. * 同步方法,会阻塞当前线程
  661. *
  662. * @param aUsername 用户名
  663. * @param aPassword 密码
  664. * @param aDevice 设备信息
  665. *
  666. * @result 错误信息
  667. *
  668. * \~english
  669. * Force logout the specified device
  670. *
  671. * device information can be obtained from getLoggedInDevicesFromServerWithUsername:password:error:
  672. *
  673. * Synchronization method will block the current thread
  674. *
  675. * @param aUsername Username
  676. * @param aPassword Password
  677. * @param aResource device resource
  678. *
  679. * @result Error
  680. */
  681. - (EMError *)kickDeviceWithUsername:(NSString *)aUsername
  682. password:(NSString *)aPassword
  683. resource:(NSString *)aResource;
  684. /*!
  685. * \~chinese
  686. * 强制指定的设备退出
  687. *
  688. * @param aUsername 用户名
  689. * @param aPassword 密码
  690. * @param aDevice 设备信息
  691. * @param aCompletionBlock 完成的回调
  692. *
  693. * \~english
  694. * Force logout the specified device
  695. *
  696. * device information can be obtained from getLoggedInDevicesFromServerWithUsername:password:error:
  697. *
  698. * @param aUsername Username
  699. * @param aPassword Password
  700. * @param aResource device resource
  701. * @param aCompletionBlock The callback block of completion
  702. */
  703. - (void)kickDeviceWithUsername:(NSString *)aUsername
  704. password:(NSString *)aPassword
  705. resource:(NSString *)aResource
  706. completion:(void (^)(EMError *aError))aCompletionBlock;
  707. /*!
  708. * \~chinese
  709. * 强制所有的登录设备退出
  710. *
  711. * 同步方法,会阻塞当前线程
  712. *
  713. * @param aUsername 用户名
  714. * @param aPassword 密码
  715. *
  716. * @result 错误信息
  717. *
  718. * \~english
  719. * Force logout all logged in device for the specified user
  720. *
  721. * Synchronization method will block the current thread
  722. *
  723. * @param aUsername Username
  724. * @param aPassword Password
  725. *
  726. * @result Error
  727. */
  728. - (EMError *)kickAllDevicesWithUsername:(NSString *)aUsername
  729. password:(NSString *)aPassword;
  730. /*!
  731. * \~chinese
  732. * 强制所有的登录设备退出
  733. *
  734. * @param aUsername 用户名
  735. * @param aPassword 密码
  736. * @param aCompletionBlock 完成的回调
  737. *
  738. * \~english
  739. * Force all logged in device to logout.
  740. *
  741. * @param aUsername Username
  742. * @param aPassword Password
  743. * @param aCompletionBlock The callback block of completion
  744. */
  745. - (void)kickAllDevicesWithUsername:(NSString *)aUsername
  746. password:(NSString *)aPassword
  747. completion:(void (^)(EMError *aError))aCompletionBlock;
  748. #pragma mark - iOS
  749. /*!
  750. * \~chinese
  751. * iOS专用,数据迁移到SDK3.0
  752. *
  753. * 同步方法,会阻塞当前线程
  754. *
  755. * 升级到SDK3.0版本需要调用该方法,开发者需要等该方法执行完后再进行数据库相关操作
  756. *
  757. * @result 是否迁移成功
  758. *
  759. * \~english
  760. * Migrate the IM database to the latest SDK version
  761. *
  762. * Synchronization method will block the current thread
  763. *
  764. * @result Return YES for success
  765. */
  766. - (BOOL)migrateDatabaseToLatestSDK;
  767. /*!
  768. * \~chinese
  769. * iOS专用,程序进入后台时,需要调用此方法断开连接
  770. *
  771. * @param aApplication UIApplication
  772. *
  773. * \~english
  774. * Disconnect from server when app enters background
  775. *
  776. * @param aApplication UIApplication
  777. */
  778. - (void)applicationDidEnterBackground:(id)aApplication;
  779. /*!
  780. * \~chinese
  781. * iOS专用,程序进入前台时,需要调用此方法进行重连
  782. *
  783. * @param aApplication UIApplication
  784. *
  785. * \~english
  786. * Reconnect to server when app enters foreground
  787. *
  788. * @param aApplication UIApplication
  789. */
  790. - (void)applicationWillEnterForeground:(id)aApplication;
  791. /*!
  792. * \~chinese
  793. * iOS专用,程序在前台收到APNs时,需要调用此方法
  794. *
  795. * @param application UIApplication
  796. * @param userInfo 推送内容
  797. *
  798. * \~english
  799. * Invoked when receiving APNs in foreground
  800. *
  801. * @param application UIApplication
  802. * @param userInfo Push content
  803. */
  804. - (void)application:(id)application didReceiveRemoteNotification:(NSDictionary *)userInfo;
  805. #pragma mark - Service Check
  806. /*!
  807. * \~chinese
  808. * 服务诊断接口,根据EMServerCheckType枚举的顺序依次诊断当前服务,并回调给开发者
  809. * 如果已经登录,默认使用登录账号
  810. *
  811. * @param aUsername 用户名
  812. * @param aPassword 密码
  813. * @param aCompletionBlock 完成的回调
  814. *
  815. * \~english
  816. * Make a diagnose for service, Diagnosis of current services according to the order of EMServerCheckType enumeration, and callback for the developer
  817. * If you have logged in, use the default login account
  818. *
  819. * @param aUsername username
  820. * @param aPassword password
  821. * @param aCompletionBlock The callback block of completion
  822. */
  823. - (void)serviceCheckWithUsername:(NSString *)aUsername
  824. password:(NSString *)aPassword
  825. completion:(void (^)(EMServerCheckType aType, EMError *aError))aCompletionBlock;
  826. #pragma mark - EM_DEPRECATED_IOS 3.2.3
  827. /*!
  828. * \~chinese
  829. * 添加回调代理
  830. *
  831. * @param aDelegate 要添加的代理
  832. *
  833. * \~english
  834. * Add delegate
  835. *
  836. * @param aDelegate Delegate
  837. */
  838. - (void)addDelegate:(id<EMClientDelegate>)aDelegate EM_DEPRECATED_IOS(3_1_0, 3_2_2, "Use -[IEMCallManager addDelegate:delegateQueue:]");
  839. #pragma mark - EM_DEPRECATED_IOS < 3.2.3
  840. /*!
  841. * \~chinese
  842. * 注册用户
  843. *
  844. * 不推荐使用,建议后台通过REST注册
  845. *
  846. * @param aUsername 用户名
  847. * @param aPassword 密码
  848. * @param aSuccessBlock 成功的回调
  849. * @param aFailureBlock 失败的回调
  850. *
  851. * \~english
  852. * Register a new user
  853. *
  854. * To enhance the reliability, registering new IM user through REST API from backend is highly recommended
  855. *
  856. * @param aUsername Username
  857. * @param aPassword Password
  858. * @param aSuccessBlock The callback block of success
  859. * @param aFailureBlock The callback block of failure
  860. *
  861. */
  862. - (void)asyncRegisterWithUsername:(NSString *)aUsername
  863. password:(NSString *)aPassword
  864. success:(void (^)())aSuccessBlock
  865. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -registerWithUsername:password:completion:");
  866. /*!
  867. * \~chinese
  868. * 登录
  869. *
  870. * @param aUsername 用户名
  871. * @param aPassword 密码
  872. * @param aSuccessBlock 成功的回调
  873. * @param aFailureBlock 失败的回调
  874. *
  875. * \~english
  876. * Login
  877. *
  878. * @param aUsername Username
  879. * @param aPassword Password
  880. * @param aSuccessBlock The callback block of success
  881. * @param aFailureBlock The callback block of failure
  882. *
  883. */
  884. - (void)asyncLoginWithUsername:(NSString *)aUsername
  885. password:(NSString *)aPassword
  886. success:(void (^)())aSuccessBlock
  887. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -loginWithUsername:password:completion");
  888. /*!
  889. * \~chinese
  890. * 退出
  891. *
  892. * @param aIsUnbindDeviceToken 是否解除device token的绑定,解除绑定后设备不会再收到消息推送
  893. * 如果传入YES, 解除绑定失败,将返回error
  894. *
  895. * @result 错误信息
  896. *
  897. * \~english
  898. * Logout
  899. *
  900. * @param aIsUnbindDeviceToken Unbind device token to disable the Apple Push Notification Service
  901. *
  902. * @result Error
  903. */
  904. - (void)asyncLogout:(BOOL)aIsUnbindDeviceToken
  905. success:(void (^)())aSuccessBlock
  906. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -logout:completion:");
  907. /*!
  908. * \~chinese
  909. * 绑定device token
  910. *
  911. * @param aDeviceToken 要绑定的token
  912. * @param aSuccessBlock 成功的回调
  913. * @param aFailureBlock 失败的回调
  914. *
  915. * \~english
  916. * Bind device token
  917. *
  918. * @param aDeviceToken Device token to bind
  919. * @param aSuccessBlock The callback block of success
  920. * @param aFailureBlock The callback block of failure
  921. */
  922. - (void)asyncBindDeviceToken:(NSData *)aDeviceToken
  923. success:(void (^)())aSuccessBlock
  924. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -registerForRemoteNotificationsWithDeviceToken:completion:");
  925. /*!
  926. * \~chinese
  927. * 设置推送消息显示的昵称
  928. *
  929. * @param aNickname 要设置的昵称
  930. * @param aSuccessBlock 成功的回调
  931. * @param aFailureBlock 失败的回调
  932. *
  933. * \~english
  934. * Set display name for push notification
  935. *
  936. * @param aNickname Push Notification display name
  937. * @param aSuccessBlock The callback block of success
  938. * @param aFailureBlock The callback block of failure
  939. *
  940. */
  941. - (void)asyncSetApnsNickname:(NSString *)aNickname
  942. success:(void (^)())aSuccessBlock
  943. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -updatePushNotifiationDisplayName:copletion");
  944. /*!
  945. * \~chinese
  946. * 从服务器获取推送属性
  947. *
  948. * @param aSuccessBlock 成功的回调
  949. * @param aFailureBlock 失败的回调
  950. *
  951. * \~english
  952. * Get apns options from the server
  953. *
  954. * @param aSuccessBlock The callback block of success
  955. * @param aFailureBlock The callback block of failure
  956. */
  957. - (void)asyncGetPushOptionsFromServer:(void (^)(EMPushOptions *aOptions))aSuccessBlock
  958. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -getPushOptionsFromServerWithCompletion:");
  959. /*!
  960. * \~chinese
  961. * 更新推送设置到服务器
  962. *
  963. * @param aSuccessBlock 成功的回调
  964. * @param aFailureBlock 失败的回调
  965. *
  966. * \~english
  967. * Update APNS options to the server
  968. *
  969. * @param aSuccessBlock The callback block of success
  970. * @param aFailureBlock The callback block of failure
  971. *
  972. */
  973. - (void)asyncUpdatePushOptionsToServer:(void (^)())aSuccessBlock
  974. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -updatePushNotificationOptionsToServerWithCompletion:");
  975. /*!
  976. * \~chinese
  977. * 上传日志到服务器
  978. *
  979. * @param aSuccessBlock 成功的回调
  980. * @param aFailureBlock 失败的回调
  981. *
  982. * \~english
  983. * Upload log to server
  984. *
  985. * @param aSuccessBlock The callback block of success
  986. * @param aFailureBlock The callback block of failure
  987. */
  988. - (void)asyncUploadLogToServer:(void (^)())aSuccessBlock
  989. failure:(void (^)(EMError *aError))aFailureBlock __deprecated_msg("Use -uploadDebugLogToServerWithCompletion:");
  990. /*!
  991. * \~chinese
  992. * iOS专用,数据迁移到SDK3.0
  993. *
  994. * 同步方法,会阻塞当前线程
  995. *
  996. * 升级到SDK3.0版本需要调用该方法,开发者需要等该方法执行完后再进行数据库相关操作
  997. *
  998. * @result 是否迁移成功
  999. *
  1000. * \~english
  1001. * iOS-specific, data migration to SDK3.0
  1002. *
  1003. * Synchronization method will block the current thread
  1004. *
  1005. * It's needed to call this method when update to SDK3.0, developers need to wait this method complete before DB related operations
  1006. *
  1007. * @result Whether migration successful
  1008. */
  1009. - (BOOL)dataMigrationTo3 __deprecated_msg("Use -migrateDatabaseToLatestSDK");
  1010. /*!
  1011. * \~chinese
  1012. * 强制指定的设备退出
  1013. *
  1014. * 同步方法,会阻塞当前线程
  1015. *
  1016. * @param aDevice 设备信息
  1017. * @param aUsername 用户名
  1018. * @param aPassword 密码
  1019. *
  1020. * @result 错误信息
  1021. *
  1022. * \~english
  1023. * Force logout the specified device
  1024. *
  1025. * device information can be obtained from getLoggedInDevicesFromServerWithUsername:password:error:
  1026. *
  1027. * Synchronization method will block the current thread
  1028. *
  1029. * @param aDevice device information <EMDeviceConfig>
  1030. * @param aUsername Username
  1031. * @param aPassword Password
  1032. *
  1033. * @result Error
  1034. */
  1035. - (EMError *)kickDevice:(EMDeviceConfig *)aDevice
  1036. username:(NSString *)aUsername
  1037. password:(NSString *)aPassword __deprecated_msg("Use - kickDeviceWithUsername:password:resource:");
  1038. /*!
  1039. * \~chinese
  1040. * 强制指定的设备退出
  1041. *
  1042. * @param aDevice 设备信息
  1043. * @param aUsername 用户名
  1044. * @param aPassword 密码
  1045. * @param aCompletionBlock 完成的回调
  1046. *
  1047. * \~english
  1048. * Force logout the specified device
  1049. *
  1050. * device information can be obtained from getLoggedInDevicesFromServerWithUsername:password:error:
  1051. *
  1052. * @param aDevice device information <EMDeviceConfig>
  1053. * @param aUsername Username
  1054. * @param aPassword Password
  1055. * @param aCompletionBlock The callback block of completion
  1056. */
  1057. - (void)kickDevice:(EMDeviceConfig *)aDevice
  1058. username:(NSString *)aUsername
  1059. password:(NSString *)aPassword
  1060. completion:(void (^)(EMError *aError))aCompletionBlock __deprecated_msg("Use - kickDeviceWithUsername:password:resource:completion:");
  1061. @end