|
@@ -45,8 +45,6 @@
|
|
|
@property (nonatomic) NSDictionary *msg;
|
|
@property (nonatomic) NSDictionary *msg;
|
|
|
@property (strong, nonatomic) NSString *bgMark;
|
|
@property (strong, nonatomic) NSString *bgMark;
|
|
|
|
|
|
|
|
-@property (nonatomic) BOOL isTokenCleared;
|
|
|
|
|
-
|
|
|
|
|
@property (strong, nonatomic) FloatingWindow *floatWindow;
|
|
@property (strong, nonatomic) FloatingWindow *floatWindow;
|
|
|
@property (nonatomic, strong) JSGController * _Nullable jsyuyinctr;
|
|
@property (nonatomic, strong) JSGController * _Nullable jsyuyinctr;
|
|
|
|
|
|
|
@@ -66,6 +64,17 @@
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
// Override point for customization after application launch.
|
|
// Override point for customization after application launch.
|
|
|
app = self;
|
|
app = self;
|
|
|
|
|
+
|
|
|
|
|
+ self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
|
|
+ self.window.backgroundColor = UIColor.blackColor;
|
|
|
|
|
+ BOOL isLoggedIn = [LoginStateManager sharedManager].isLoggedIn;
|
|
|
|
|
+ if (isLoggedIn) {
|
|
|
|
|
+ [self initDataAfterLogin:YES];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [self openLoginController];
|
|
|
|
|
+ }
|
|
|
|
|
+ [self.window makeKeyAndVisible];
|
|
|
|
|
+
|
|
|
BuglyConfig *config = [[BuglyConfig alloc] init];
|
|
BuglyConfig *config = [[BuglyConfig alloc] init];
|
|
|
config.reportLogLevel = BuglyLogLevelVerbose;
|
|
config.reportLogLevel = BuglyLogLevelVerbose;
|
|
|
[Bugly startWithAppId:@"1d9e6b546a" config:config];
|
|
[Bugly startWithAppId:@"1d9e6b546a" config:config];
|
|
@@ -77,11 +86,9 @@
|
|
|
|
|
|
|
|
[self initJSMSDK];
|
|
[self initJSMSDK];
|
|
|
[self setupListener];
|
|
[self setupListener];
|
|
|
- [self checkLoginState:launchOptions];
|
|
|
|
|
[self registerPushright];
|
|
[self registerPushright];
|
|
|
[self setupCallProvider];
|
|
[self setupCallProvider];
|
|
|
[self startNetworkReachability];
|
|
[self startNetworkReachability];
|
|
|
- _isTokenCleared=YES;
|
|
|
|
|
|
|
|
|
|
_floatWindow = [[FloatingWindow alloc] initWithFrame:self.window.bounds];
|
|
_floatWindow = [[FloatingWindow alloc] initWithFrame:self.window.bounds];
|
|
|
[_floatWindow hide];
|
|
[_floatWindow hide];
|
|
@@ -212,7 +219,7 @@
|
|
|
|
|
|
|
|
-(void)setupListener{
|
|
-(void)setupListener{
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLoginSucc) name:nkonLoginSucc object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLoginSucc) name:nkonLoginSucc object:nil];
|
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLogoutSucc) name:nkonLogoutSucc object:nil];
|
|
|
|
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLogout) name:nkonLogoutSucc object:nil];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addFriend) name:nkonAddFriendNote object:nil];;
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addFriend) name:nkonAddFriendNote object:nil];;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -264,31 +271,6 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#pragma mark login sttate
|
|
|
|
|
-- (void)checkLoginState:(NSDictionary *)launchOptions{
|
|
|
|
|
- [[LoginStateManager sharedManager] getUserInfo];
|
|
|
|
|
- [LoginStateManager sharedManager].checkLoginState = ^(BOOL isLogin) {
|
|
|
|
|
- if (isLogin) {
|
|
|
|
|
- self.isLogin =TRUE;
|
|
|
|
|
-
|
|
|
|
|
- [self updivicetoken];
|
|
|
|
|
- [self updiviceVoIPtoken];
|
|
|
|
|
- [self sartWebsocket];
|
|
|
|
|
- [self openFMDB];
|
|
|
|
|
- [self openMainController];
|
|
|
|
|
- // 检查是否需要显示启动锁屏
|
|
|
|
|
- if ([[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
|
|
|
|
|
- [self showLockScreen];
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
- self.shouldShowLock = NO;
|
|
|
|
|
- }
|
|
|
|
|
- }else{
|
|
|
|
|
- [self openLoginController];
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-(void)updivicetoken{
|
|
-(void)updivicetoken{
|
|
|
NSString *token =[UDManager.shareInstance getSDManager:dkpushtoken];
|
|
NSString *token =[UDManager.shareInstance getSDManager:dkpushtoken];
|
|
|
NSDictionary *usinfo = [UDManager.shareInstance getDDManager:dkuserinfo];
|
|
NSDictionary *usinfo = [UDManager.shareInstance getDDManager:dkuserinfo];
|
|
@@ -301,7 +283,6 @@
|
|
|
NSString *bgMark = [NSString stringWithFormat:@"上传推送token:%ld",token.length];
|
|
NSString *bgMark = [NSString stringWithFormat:@"上传推送token:%ld",token.length];
|
|
|
[Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
|
|
[Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
|
|
|
[UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
|
|
[UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
|
|
|
- self->_isTokenCleared=NO;
|
|
|
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:res options:0 error:nil];
|
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:res options:0 error:nil];
|
|
|
if (!jsonData) {
|
|
if (!jsonData) {
|
|
|
NSLog(@"Got an error:");
|
|
NSLog(@"Got an error:");
|
|
@@ -330,7 +311,6 @@
|
|
|
|
|
|
|
|
[UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
|
|
[UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
|
|
|
NSLog(@"updiviceVoIPtoken:%@",[res description]);
|
|
NSLog(@"updiviceVoIPtoken:%@",[res description]);
|
|
|
- self->_isTokenCleared=NO;
|
|
|
|
|
} fail:^(NSError * _Nonnull error) {
|
|
} fail:^(NSError * _Nonnull error) {
|
|
|
NSLog(@"--%@",error);
|
|
NSLog(@"--%@",error);
|
|
|
}];
|
|
}];
|
|
@@ -808,63 +788,36 @@
|
|
|
#pragma mark -user state and note
|
|
#pragma mark -user state and note
|
|
|
|
|
|
|
|
-(void)onLoginSucc{
|
|
-(void)onLoginSucc{
|
|
|
- self.isLogin =TRUE;
|
|
|
|
|
- [self openFMDB];
|
|
|
|
|
- [self openMainController];
|
|
|
|
|
- [self updivicetoken];
|
|
|
|
|
- [self updiviceVoIPtoken];
|
|
|
|
|
- [self sartWebsocket];
|
|
|
|
|
|
|
+ [self initDataAfterLogin:NO];
|
|
|
}
|
|
}
|
|
|
--(void)onLogoutSucc{
|
|
|
|
|
|
|
+-(void)onLogout{
|
|
|
self.isLogin =false;
|
|
self.isLogin =false;
|
|
|
- NSLog(@"1-----------------1");
|
|
|
|
|
-// [GDBManager.shareInstance delLocalmsglistTable:userid];
|
|
|
|
|
-// [GDBManager.shareInstance delchatlistTable:nil fail:nil];
|
|
|
|
|
-// [GDBManager.shareInstance deleteDB];
|
|
|
|
|
- [UDManager.shareInstance removeUDManager:gkeytoken];
|
|
|
|
|
- [UDManager.shareInstance removeUDManager:dkuserloginId];
|
|
|
|
|
- [UDManager.shareInstance removeUDManager:dkuserinfo];
|
|
|
|
|
- [UDManager.shareInstance removeUDManager:dkuserId];
|
|
|
|
|
- [self clearVoipToken];
|
|
|
|
|
|
|
+ [[LoginStateManager sharedManager] cleanLoginState];
|
|
|
[self openLoginController];
|
|
[self openLoginController];
|
|
|
- [self endWebsocket];
|
|
|
|
|
[self resetBadgeCount];
|
|
[self resetBadgeCount];
|
|
|
[self resetAddFriendBadgeCount];
|
|
[self resetAddFriendBadgeCount];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
--(void)clearVoipToken{
|
|
|
|
|
-
|
|
|
|
|
- NSString *voiptoken = [UDManager.shareInstance getSDManager:dkvoiptoken];
|
|
|
|
|
- NSLog(@"voiptoken:%@",voiptoken);
|
|
|
|
|
- if([voiptoken isKindOfClass:[NSString class]]&&voiptoken.length>10){
|
|
|
|
|
- NSDictionary *dic = @{
|
|
|
|
|
- @"voipTk":voiptoken
|
|
|
|
|
- };
|
|
|
|
|
- [UserNetApi clearVoipTk:dic succ:^(int code, NSDictionary * res) {
|
|
|
|
|
- NSLog(@"clearVoipTk:%@",res);
|
|
|
|
|
- self->_isTokenCleared=YES;
|
|
|
|
|
- } fail:^(NSError * _Nonnull error) {
|
|
|
|
|
-
|
|
|
|
|
- }];
|
|
|
|
|
|
|
+- (void)initDataAfterLogin:(BOOL)needRequest {
|
|
|
|
|
+ self.isLogin =TRUE;
|
|
|
|
|
+ [self openFMDB];
|
|
|
|
|
+ [self openMainController];
|
|
|
|
|
+ [self updivicetoken];
|
|
|
|
|
+ [self updiviceVoIPtoken];
|
|
|
|
|
+ [self sartWebsocket];
|
|
|
|
|
+ if ([[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
|
|
|
|
|
+ [self showLockScreen];
|
|
|
|
|
+ } else{
|
|
|
|
|
+ self.shouldShowLock = NO;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- NSString *pushtoken = [UDManager.shareInstance getSDManager:dkpushtoken];
|
|
|
|
|
- NSLog(@"voiptoken:%@",pushtoken);
|
|
|
|
|
- if([pushtoken isKindOfClass:[NSString class]]&&pushtoken.length>10){
|
|
|
|
|
- NSDictionary *dic = @{
|
|
|
|
|
- @"registrationId":pushtoken
|
|
|
|
|
- };
|
|
|
|
|
- [UserNetApi clearRegistrationId:dic succ:^(int code, NSDictionary * res) {
|
|
|
|
|
- NSLog(@"clearRegistrationId:%@",res);
|
|
|
|
|
- self->_isTokenCleared=YES;
|
|
|
|
|
- } fail:^(NSError * _Nonnull error) {
|
|
|
|
|
|
|
+ if (needRequest) {
|
|
|
|
|
+ [[LoginStateManager sharedManager] requestUserInfoWith:^(BOOL isSuccess) {
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
#pragma mark mainControllor Manager
|
|
#pragma mark mainControllor Manager
|
|
|
-(void)openMainController{
|
|
-(void)openMainController{
|
|
|
NSLog(@"openMainController");
|
|
NSLog(@"openMainController");
|
|
@@ -951,25 +904,10 @@
|
|
|
[[GWebSocket shareInstance] connectWebSocket];
|
|
[[GWebSocket shareInstance] connectWebSocket];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
--(void)endWebsocket{
|
|
|
|
|
- [[GWebSocket shareInstance] closeWebSocket];
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
#pragma mark init DB
|
|
#pragma mark init DB
|
|
|
--(void)openFMDB{
|
|
|
|
|
- [GDBManager.shareInstance createDatabase:^(NSArray * _Nullable array) {
|
|
|
|
|
- [GDBManager.shareInstance createLocalMSGtable:^(NSArray * _Nullable array) {
|
|
|
|
|
- } fail:^(NSString * _Nullable error) {
|
|
|
|
|
- }];
|
|
|
|
|
- [GDBManager.shareInstance createChattable:^(NSArray * _Nullable array) {
|
|
|
|
|
- } fail:^(NSString * _Nullable error) {
|
|
|
|
|
- }];
|
|
|
|
|
- [GDBManager.shareInstance createLastreadtimetable:^(NSArray * _Nullable array) {
|
|
|
|
|
- } fail:^(NSString * _Nullable error) {
|
|
|
|
|
- }];
|
|
|
|
|
- } fail:^(NSString * _Nullable error) {
|
|
|
|
|
-
|
|
|
|
|
- }];
|
|
|
|
|
|
|
+-(void)openFMDB {
|
|
|
|
|
+ [[GDBManager shareInstance] initDataBase];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|