HyphenateChatSDK 4.12.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
595- (EMError *_Nullable)loginWithUsername:(NSString *_Nonnull)aUsername
596 agoraToken:(NSString *_Nonnull)aAgoraToken EM_DEPRECATED_IOS(3_8_9, 4_2_0,"Use -EMClient loginWithUsername:token instead");
597
619- (void)loginWithUsername:(NSString *_Nonnull)aUsername
620 agoraToken:(NSString *_Nonnull)aAgoraToken
621 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");
622
646- (EMError *_Nullable)renewToken:(NSString *_Nonnull)newToken;
647
671- (void)renewToken:(NSString *_Nonnull)newToken completion:(void (^_Nullable)(EMError* _Nullable aError))aCompletionBlock;
672
673#pragma mark - Logout
674
699- (EMError *_Nullable)logout:(BOOL)aIsUnbindDeviceToken;
700
724- (void)logout:(BOOL)aIsUnbindDeviceToken
725 completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
726
727#pragma mark - PushKit
728
752- (EMError *_Nullable)bindPushKitToken:(NSData *_Nullable)aPushToken;
753
775- (void)registerPushKitToken:(NSData *_Nullable)aPushToken
776 completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
777
801- (EMError *_Nullable)unBindPushKitToken;
802
824- (void)unRegisterPushKitTokenWithCompletion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
825
826#pragma mark - APNs
827
852- (EMError *_Nullable)bindDeviceToken:(NSData *_Nonnull)aDeviceToken;
853
875- (void)registerForRemoteNotificationsWithDeviceToken:(NSData *_Nonnull)aDeviceToken
876 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
877
901- (void)registerForRemoteNotificationsWithCertName:(NSString *_Nonnull)aCertName
902 deviceToken:(NSData *_Nonnull)aDeviceToken
903 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
904
927- (void)bindFCMToken:(NSString* _Nonnull)aFCMToken
928 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
929
930#pragma mark - Log
931
949- (EMError *_Nullable)uploadLogToServer;
950
962- (void)uploadDebugLogToServerWithCompletion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
963
987- (NSString *_Nullable)getLogFilesPath:(EMError **_Nullable)pError;
988
1008- (void)getLogFilesPathWithCompletion:(void (^_Nullable)(NSString *_Nullable aPath, EMError * _Nullable aError))aCompletionBlock;
1009
1029- (void)log:(NSString *_Nonnull)aLog;
1030
1044- (void)addLogDelegate:(id<EMLogDelegate>_Nonnull)aDelegate
1045 delegateQueue:(dispatch_queue_t _Nullable )aQueue NS_SWIFT_NAME(addLog(delegate:queue:));
1046
1058- (void)removeLogDelegate:(id<EMLogDelegate>_Nonnull)aDelegate NS_SWIFT_NAME(removeLog(delegate:));
1059
1060#pragma mark - Multi Devices
1061
1085- (NSArray<EMDeviceConfig*> *_Nullable)getLoggedInDevicesFromServerWithUsername:(NSString * _Nonnull)aUsername
1086 password:(NSString * _Nonnull)aPassword
1087 error:(EMError ** _Nullable)pError;
1088
1109- (void)getLoggedInDevicesFromServerWithUsername:(NSString *_Nonnull)aUsername
1110 password:(NSString *_Nonnull)aPassword
1111 completion:(void (^_Nullable)(NSArray<EMDeviceConfig*> * _Nullable aList, EMError *_Nullable aError))aCompletionBlock;
1112
1133- (void)getLoggedInDevicesFromServerWithUserId:(NSString *_Nonnull)aUserID
1134 token:(NSString *_Nonnull)aToken
1135 completion:(void (^_Nullable)(NSArray<EMDeviceConfig*> * _Nullable aList, EMError *_Nullable aError))aCompletionBlock;
1136
1164- (EMError *_Nullable)kickDeviceWithUsername:(NSString *_Nonnull)aUsername
1165 password:(NSString *_Nonnull)aPassword
1166 resource:(NSString *_Nonnull)aResource;
1167
1168
1194- (void)kickDeviceWithUsername:(NSString *_Nonnull)aUsername
1195 password:(NSString *_Nonnull)aPassword
1196 resource:(NSString *_Nonnull)aResource
1197 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1198
1224- (void)kickDeviceWithUserId:(NSString *_Nonnull)aUserID
1225 token:(NSString *_Nonnull)aToken
1226 resource:(NSString *_Nonnull)aResource
1227 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1228
1248- (void)kickAllDevicesWithUserId:(NSString *_Nonnull)aUserID
1249 token:(NSString *_Nonnull)aToken
1250 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1251
1273- (EMError *_Nullable)kickAllDevicesWithUsername:(NSString *_Nonnull)aUsername
1274 password:(NSString *_Nonnull)aPassword;
1275
1296- (void)kickAllDevicesWithUsername:(NSString *_Nonnull)aUsername
1297 password:(NSString *_Nonnull)aPassword
1298 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
1299
1311- (EMDeviceConfig *)getDeviceConfig:(EMError **)pError;
1312
1313#pragma mark - iOS
1314
1315
1329- (void)applicationDidEnterBackground:(id _Nonnull )aApplication;
1330
1344- (void)applicationWillEnterForeground:(id _Nonnull )aApplication;
1345
1361- (void)application:(id _Nonnull)application didReceiveRemoteNotification:(NSDictionary * _Nullable)userInfo;
1362
1363#pragma mark - Service Check
1364
1392- (void)serviceCheckWithUsername:(NSString *_Nonnull)aUsername
1393 password:(NSString *_Nonnull)aPassword
1394 completion:(void (^_Nullable)(EMServerCheckType aType, EMError *_Nullable aError))aCompletionBlock __deprecated_msg("This method is deprecated");
1395@end
Definition: EMClient.h:62
Definition: EMDeviceConfig.h:25
Definition: EMError.h:27
Definition: EMOptions.h:52
Definition: EMPushOptions.h:58
Definition: EMClientDelegate.h:47
Definition: EMLogDelegate.h:18
Definition: EMMultiDevicesDelegate.h:80