HyphenateChatSDK 4.16.0
EMClient.h
1
8#import <Foundation/Foundation.h>
9
10#import "EMClientDelegate.h"
11#import "EMError.h"
12#import "EMMultiDevicesDelegate.h"
13#import "EMOptions.h"
14#import "EMPushOptions.h"
15
16#import "IEMChatManager.h"
17#import "IEMChatroomManager.h"
18#import "IEMContactManager.h"
19#import "IEMGroupManager.h"
20#import "IEMThreadManager.h"
21#import "IEMPushManager.h"
22#import "IEMUserInfoManager.h"
23#import "IEMPresenceManager.h"
24#import "IEMStatisticsManager.h"
25
26#import "EMDeviceConfig.h"
27#import "EMLocalNotificationManager.h"
28#import "EMLogDelegate.h"
29
43typedef NS_ENUM(NSInteger, EMServerCheckType) {
44 EMServerCheckAccountValidation = 0,
45 EMServerCheckGetDNSListFromServer,
46 EMServerCheckGetTokenFromServer,
47 EMServerCheckDoLogin,
48 EMServerCheckDoLogout,
49};
50
61@interface EMClient : NSObject
62{
63 EMPushOptions *_pushOptions;
64}
65
73@property(nonatomic, strong, readonly) NSString * _Nonnull version;
74
82@property(nonatomic, strong, readonly) NSString * _Nullable currentUsername;
83
91@property(nonatomic, strong, readonly) EMOptions * _Nonnull options;
92
100@property(nonatomic, strong, readonly) id<IEMChatManager> _Nullable chatManager;
101
109@property(nonatomic, strong, readonly) id<IEMContactManager> _Nullable contactManager;
110
118@property(nonatomic, strong, readonly) id<IEMGroupManager> _Nullable groupManager;
119
127@property (nonatomic, strong, readonly) id<IEMThreadManager> _Nullable threadManager;
128
136@property(nonatomic, strong, readonly) id<IEMChatroomManager> _Nullable roomManager;
137
145@property (nonatomic, strong, readonly) id<IEMPushManager> _Nullable pushManager;
146
165@property(nonatomic, readonly) BOOL isAutoLogin;
166
178@property(nonatomic, readonly) BOOL isLoggedIn;
179
190@property(nonatomic, readonly) BOOL isConnected;
191
203@property(nonatomic, readonly) NSString * _Nullable accessUserToken;
204
212@property(nonatomic, strong, readonly) id<IEMUserInfoManager> _Nullable userInfoManager;
213
221@property (nonatomic, strong, readonly) id<IEMPresenceManager> _Nullable presenceManager;
222
230@property (nonatomic, strong, readonly) id<IEMStatisticsManager> _Nullable statisticsManager;
231
232-(instancetype _Nonnull ) init __attribute__((unavailable("call sharedClient instead")));
233-(instancetype _Nonnull ) copy __attribute__((unavailable("call sharedClient instead")));
234-(instancetype _Nonnull ) mutableCopy __attribute__((unavailable("call sharedClient instead")));
242+ (instancetype _Nonnull )sharedClient;
243
244
252- (NSString *)version;
253
254#pragma mark - Delegate
255
268- (void)addDelegate:(id<EMClientDelegate>_Nonnull)aDelegate
269 delegateQueue:(dispatch_queue_t _Nullable )aQueue;
270
282- (void)removeDelegate:(id _Nonnull )aDelegate;
283
297- (void)addMultiDevicesDelegate:(id<EMMultiDevicesDelegate>_Nonnull)aDelegate
298 delegateQueue:(dispatch_queue_t _Nullable )aQueue NS_SWIFT_NAME(addMultiDevices(delegate:queue:));
299
311- (void)removeMultiDevicesDelegate:(id<EMMultiDevicesDelegate>_Nonnull)aDelegate;
312
313#pragma mark - Initialize SDK
314
330- (EMError *_Nullable)initializeSDKWithOptions:(EMOptions * _Nonnull )aOptions;
331
332#pragma mark - Change AppKey
333
355- (EMError *_Nullable)changeAppkey:(NSString * _Nonnull)aAppkey;
356
378- (EMError *_Nullable)changeAppId:(NSString * _Nonnull)aAppId;
379
380#pragma mark - User Registration
409- (EMError *_Nullable)registerWithUsername:(NSString * _Nonnull)aUsername
410 password:(NSString * _Nonnull)aPassword;
411
436- (void)registerWithUsername:(NSString *_Nonnull)aUsername
437 password:(NSString *_Nonnull)aPassword
438 completion:(void (^_Nullable)(NSString * _Nonnull aUsername, EMError * _Nullable aError))aCompletionBlock;
439
440#pragma mark - Login
441
462- (void)fetchTokenWithUsername:(NSString *_Nonnull)aUsername
463 password:(NSString *_Nonnull)aPassword
464 completion:(void (^_Nullable)(NSString * _Nullable aToken, EMError * _Nullable aError))aCompletionBlock;
465
491- (EMError *_Nullable)loginWithUsername:(NSString *_Nonnull)aUsername
492 password:(NSString *_Nonnull)aPassword EM_DEPRECATED_IOS(3_0_0, 4_5_0,"Use -EMClient loginWithUsername:token:completion instead");
493
518- (void)loginWithUsername:(NSString *_Nonnull)aUsername
519 password:(NSString *_Nonnull)aPassword
520 completion:(void (^_Nullable)(NSString * _Nonnull aUsername, EMError *_Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(3_0_0, 4_5_0,"Use -EMClient loginWithUsername:token:completion instead");
521
547- (EMError *_Nullable)loginWithUsername:(NSString *_Nonnull)aUsername
548 token:(NSString *_Nonnull)aToken;
549
570- (void)loginWithUsername:(NSString *_Nonnull)aUsername
571 token:(NSString *_Nonnull)aToken
572 completion:(void (^_Nullable)(NSString * _Nonnull aUsername, EMError *_Nullable aError))aCompletionBlock;
573
574
596- (EMError *_Nullable)loginWithUsername:(NSString *_Nonnull)aUsername
597 agoraToken:(NSString *_Nonnull)aAgoraToken EM_DEPRECATED_IOS(3_8_9, 4_2_0,"Use -EMClient loginWithUsername:token instead");
598
620- (void)loginWithUsername:(NSString *_Nonnull)aUsername
621 agoraToken:(NSString *_Nonnull)aAgoraToken
622 completion:(void (^_Nullable)(NSString * _Nonnull aUsername, EMError *_Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(3_8_9, 4_2_0,"Use -EMClient loginWithUsername:token:completion instead");
623
647- (EMError *_Nullable)renewToken:(NSString *_Nonnull)newToken;
648
672- (void)renewToken:(NSString *_Nonnull)newToken completion:(void (^_Nullable)(EMError* _Nullable aError))aCompletionBlock;
673
674#pragma mark - Logout
675
700- (EMError *_Nullable)logout:(BOOL)aIsUnbindDeviceToken;
701
725- (void)logout:(BOOL)aIsUnbindDeviceToken
726 completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
727
728#pragma mark - PushKit
729
753- (EMError *_Nullable)bindPushKitToken:(NSData *_Nullable)aPushToken;
754
776- (void)registerPushKitToken:(NSData *_Nullable)aPushToken
777 completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
778
802- (EMError *_Nullable)unBindPushKitToken;
803
825- (void)unRegisterPushKitTokenWithCompletion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
826
827#pragma mark - APNs
828
853- (EMError *_Nullable)bindDeviceToken:(NSData *_Nonnull)aDeviceToken;
854
876- (void)registerForRemoteNotificationsWithDeviceToken:(NSData *_Nonnull)aDeviceToken
877 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
878
904- (void)getRTCTokenWithChannel:(NSString* _Nullable)aChannelName
905 completion:(void (^_Nonnull)(NSUInteger rtcUId,NSString * _Nullable aToken,NSInteger expiredTs, EMError *_Nullable aError))aCompletionBlock;
906
924- (void)getUserIdByRTCUIds:(NSArray<NSNumber*>* _Nonnull)uIds completion:(void (^_Nullable)(NSDictionary<NSNumber*,NSString*> * _Nullable accountInfos, EMError *_Nullable aError))aCompletionBlock;
925
949- (void)registerForRemoteNotificationsWithCertName:(NSString *_Nonnull)aCertName
950 deviceToken:(NSData *_Nonnull)aDeviceToken
951 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
952
975- (void)bindFCMToken:(NSString* _Nonnull)aFCMToken
976 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
977
978#pragma mark - Log
979
997- (EMError *_Nullable)uploadLogToServer;
998
1010- (void)uploadDebugLogToServerWithCompletion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1011
1035- (NSString *_Nullable)getLogFilesPath:(EMError **_Nullable)pError;
1036
1056- (void)getLogFilesPathWithCompletion:(void (^_Nullable)(NSString *_Nullable aPath, EMError * _Nullable aError))aCompletionBlock;
1057
1077- (void)log:(NSString *_Nonnull)aLog;
1078
1092- (void)addLogDelegate:(id<EMLogDelegate>_Nonnull)aDelegate
1093 delegateQueue:(dispatch_queue_t _Nullable )aQueue NS_SWIFT_NAME(addLog(delegate:queue:));
1094
1106- (void)removeLogDelegate:(id<EMLogDelegate>_Nonnull)aDelegate NS_SWIFT_NAME(removeLog(delegate:));
1107
1108#pragma mark - Multi Devices
1109
1133- (NSArray<EMDeviceConfig*> *_Nullable)getLoggedInDevicesFromServerWithUsername:(NSString * _Nonnull)aUsername
1134 password:(NSString * _Nonnull)aPassword
1135 error:(EMError ** _Nullable)pError;
1136
1157- (void)getLoggedInDevicesFromServerWithUsername:(NSString *_Nonnull)aUsername
1158 password:(NSString *_Nonnull)aPassword
1159 completion:(void (^_Nullable)(NSArray<EMDeviceConfig*> * _Nullable aList, EMError *_Nullable aError))aCompletionBlock;
1160
1181- (void)getLoggedInDevicesFromServerWithUserId:(NSString *_Nonnull)aUserID
1182 token:(NSString *_Nonnull)aToken
1183 completion:(void (^_Nullable)(NSArray<EMDeviceConfig*> * _Nullable aList, EMError *_Nullable aError))aCompletionBlock;
1184
1212- (EMError *_Nullable)kickDeviceWithUsername:(NSString *_Nonnull)aUsername
1213 password:(NSString *_Nonnull)aPassword
1214 resource:(NSString *_Nonnull)aResource;
1215
1216
1242- (void)kickDeviceWithUsername:(NSString *_Nonnull)aUsername
1243 password:(NSString *_Nonnull)aPassword
1244 resource:(NSString *_Nonnull)aResource
1245 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1246
1272- (void)kickDeviceWithUserId:(NSString *_Nonnull)aUserID
1273 token:(NSString *_Nonnull)aToken
1274 resource:(NSString *_Nonnull)aResource
1275 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1276
1296- (void)kickAllDevicesWithUserId:(NSString *_Nonnull)aUserID
1297 token:(NSString *_Nonnull)aToken
1298 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1299
1321- (EMError *_Nullable)kickAllDevicesWithUsername:(NSString *_Nonnull)aUsername
1322 password:(NSString *_Nonnull)aPassword;
1323
1344- (void)kickAllDevicesWithUsername:(NSString *_Nonnull)aUsername
1345 password:(NSString *_Nonnull)aPassword
1346 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1347
1359- (EMDeviceConfig *)getDeviceConfig:(EMError **)pError;
1360
1361#pragma mark - iOS
1362
1363
1377- (void)applicationDidEnterBackground:(id _Nonnull )aApplication;
1378
1392- (void)applicationWillEnterForeground:(id _Nonnull )aApplication;
1393
1409- (void)application:(id _Nonnull)application didReceiveRemoteNotification:(NSDictionary * _Nullable)userInfo;
1410
1411#pragma mark - Service Check
1412
1440- (void)serviceCheckWithUsername:(NSString *_Nonnull)aUsername
1441 password:(NSString *_Nonnull)aPassword
1442 completion:(void (^_Nullable)(EMServerCheckType aType, EMError *_Nullable aError))aCompletionBlock __deprecated_msg("This method is deprecated");
1443@end
Definition: EMClient.h:62
Definition: EMDeviceConfig.h:25
Definition: EMError.h:27
Definition: EMOptions.h:70
Definition: EMPushOptions.h:58
Definition: EMClientDelegate.h:47
Definition: EMLogDelegate.h:18
Definition: EMMultiDevicesDelegate.h:78