EMClient.h 31 KB

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