From 2197e837490f5083d18d9fdb97265d1e0f04832a Mon Sep 17 00:00:00 2001 From: 单军华 <WindShan@danjunhuas-MacBook-Pro.local> Date: Fri, 20 Apr 2018 12:01:38 +0800 Subject: [PATCH] no message --- pregnancy_guard/BaseProject/AppDelegate.m | 106 +++++++++++++++++++++++++++-------------------------- 1 files changed, 54 insertions(+), 52 deletions(-) diff --git a/pregnancy_guard/BaseProject/AppDelegate.m b/pregnancy_guard/BaseProject/AppDelegate.m index 95422c7..7771171 100644 --- a/pregnancy_guard/BaseProject/AppDelegate.m +++ b/pregnancy_guard/BaseProject/AppDelegate.m @@ -19,6 +19,7 @@ #import "HomePage.h" #import "SegmentedPage.h" +#import "CBMoralManager.h" #import "SettingPage.h" #import "PhotosPage.h" #import "MinePage.h" @@ -27,6 +28,9 @@ #import "HistoryRecordPage.h" @interface AppDelegate () +{ + NSMutableArray *notifyingCharacteristicsArray; +} @property (nonatomic) Reachability *hostReachability; @property (nonatomic) Reachability *internetReachability; @@ -93,11 +97,10 @@ // ������������������������������������BaiduMapManager self.mapManager = [[BMKMapManager alloc]init]; - BOOL ret = [self.mapManager start:@"HRr8jBYNgRoXgRGHyIg8oC1yYwIUk0IG" generalDelegate:self]; - if (!ret) { - NSLog(@"manager start failed!"); - } - +// BOOL ret = [self.mapManager start:@"ZiqQxvKGjZVNbITouYn7dIwDjb1CbKcy" generalDelegate:self]; +// if (!ret) { +// NSLog(@"manager start failed!"); +// } // ������������������ self.hostReachability = [Reachability reachabilityWithHostName:@"www.baidu.com"]; @@ -107,9 +110,9 @@ [self.internetReachability startNotifier]; [self updateInterfaceWithReachability:self.internetReachability]; - //_currentDevice = _selectedDevice.mac; - [self showHomePage2]; + + [self showLoginPage]; //������������:NSException //��������������������������������� @@ -171,13 +174,50 @@ - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + + if (!notifyingCharacteristicsArray) + { + notifyingCharacteristicsArray = [NSMutableArray array]; + } + + /* Stop notification of characteristics while enter in background */ + for (CBService *service in [[CBMoralManager sharedManager] foundServices]) + { + for (CBCharacteristic *characteristic in service.characteristics) + { + if (characteristic.isNotifying && ![characteristic.UUID isEqual:BOOT_LOADER_CHARACTERISTIC_UUID]) + { + [[[CBMoralManager sharedManager] myPeripheral] setNotifyValue:NO forCharacteristic:characteristic]; + [notifyingCharacteristicsArray addObject:characteristic]; + } + } + + } } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + + /* Enable notification of characteristics while enter in foreground */ + + if (notifyingCharacteristicsArray) + { + for (CBCharacteristic *characteristic in notifyingCharacteristicsArray) + { + if (![characteristic.UUID isEqual:BOOT_LOADER_CHARACTERISTIC_UUID]) + { + [[[CBMoralManager sharedManager] myPeripheral] setNotifyValue:YES forCharacteristic:characteristic]; + } + } + } } + +- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings +{ + NSLog(@"Registered to receive local notification..."); +} - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. @@ -219,14 +259,13 @@ { //[UserDefault stringForKey:@"user_id"] - NSString *path = [[NSString alloc] initWithFormat:GET_INFO]; + NSString *path = [[NSString alloc] initWithFormat:USER_GETINFO]; CommonReqModel * model = [[CommonReqModel alloc] init]; - model.userID = [UserDefault stringForKey:@"user_id"]; - model.opt = [UserDefault stringForKey:@"opt"]; + model.phone = [UserDefault stringForKey:@"phone"]; MPWeakSelf(self); - [NetworkSingleton networkingPostMethod:model.toDic urlName:path success:^(id responseBody) + [NetworkSingleton networkingGetMethod:model.toDic urlName:path success:^(id responseBody) { MPStrongSelf(self); BaseResModel * resModel = [Global toBaseModel:responseBody]; @@ -244,15 +283,12 @@ // ������������������ [UserDefault setObject:@"1" forKey:@"isLogin"]; [UserDefault setObject:userModel._id forKey:@"user_id"]; - [UserDefault setObject:userModel.username forKey:@"username"]; + [UserDefault setObject:userModel.phone forKey:@"phone"]; [UserDefault setObject:userModel.password forKey:@"password"]; [UserDefault setObject:userModel.nickname forKey:@"nickname"]; - if(userModel.opt == 2) - { - [UserDefault setObject:userModel.hotel_id forKey:@"hotel_id"]; - } - - [UserDefault setObject:[NSString stringWithFormat:@"%d",userModel.opt] forKey:@"opt"];//opt=1���������������������opt=2������������������ + [UserDefault setObject:userModel.refresh_frequency forKey:@"refresh_frequency"]; + [UserDefault setObject:userModel.is_open_upload forKey:@"is_open_upload"]; + [UserDefault setObject:userModel.video forKey:@"video"]; [UserDefault synchronize];//������synchronize���������������������������������,���������������NSUserDefaults������������������������������������ // ��������������� @@ -275,40 +311,6 @@ { [UserDefault setObject:@"0" forKey:@"isLogin"]; //[Global alertMessageEx:error title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; - }]; - -} - -//flr ������ 0 --(void) sendControl:(NSString*)device controlkey:(NSString*)key floor:(NSString*)flr funIndex:(NSString*)fun -{ - -// NSString * device = @"f0fe6b156ebd"; -// NSString * key = @"7"; -// NSString * flr = [NSString stringWithFormat:@"%ld",row+1]; -// NSString * fun = [NSString stringWithFormat:@"%d",open == YES? 1:0]; - NSString *path = [[NSString alloc] initWithFormat:@"%@", [NSString stringWithFormat:Moral_Device_Url,device,key,flr,fun]]; - - NSMutableDictionary *param = [[NSMutableDictionary alloc] init]; - - //MPWeakSelf(self); - LOG_INFO(@"%@",path); - [NetworkSingleton networkingPostMethod:param urlName:path success:^(id responseBody) - { - // BaseResModel * resModel = [Global toBaseModel:responseBody]; - // if(resModel.code == 0) - // { - // [Global alertMessageEx:@"������������!" title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; - // [weakself.navigationController popViewControllerAnimated:YES]; - // } - // else - // { - // [Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; - // } - } - failure:^(NSString *error) - { - [Global alertMessageEx:error title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; }]; } -- Gitblit v1.8.0