diff --git a/Ifish/AppDelegate.h b/Ifish/AppDelegate.h index fc8a441..4dbf1f8 100644 --- a/Ifish/AppDelegate.h +++ b/Ifish/AppDelegate.h @@ -40,6 +40,8 @@ +(NSString*)getAppVersion; @property (strong, nonatomic) NSString *token; + +@property (strong, nonatomic) NSDictionary* remoteNotification;//如果是点击通知打开的app,则json有数据 //摄像头处于后台 @property (nonatomic) BOOL isGoBack; //设备处于后台 diff --git a/Ifish/AppDelegate.m b/Ifish/AppDelegate.m index 9364e8a..0c48cf0 100644 --- a/Ifish/AppDelegate.m +++ b/Ifish/AppDelegate.m @@ -186,9 +186,10 @@ NSLog(@"\n ====== launchOptions: %@",launchOptions); NSDictionary *pushNotificationKey = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if (pushNotificationKey) { + self.remoteNotification = pushNotificationKey; // 这里定义自己的处理方式 // 如需要代码控制 BadgeNum (icon右上角的数字等操作) - // [UIApplication sharedApplication].applicationIconBadgeNumber = 10; + //[UIApplication sharedApplication].applicationIconBadgeNumber = 10; } } /** @@ -206,16 +207,6 @@ */ // 获取推送消息 islaunchedByNotification 标识用户是否通过点击通知消息进入本应用 即userInfo - NSDictionary* remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; - NSLog(@"%@",remoteNotification); - - if (remoteNotification) { - _islaunchedByNotification=YES; - launchedByNotification = YES; - }else{ - _islaunchedByNotification=NO; - launchedByNotification = NO; - } /** * TalkingData 统计工具 @@ -270,7 +261,7 @@ // 如果是5,autoSizeScaleX=1,autoSizeScaleY=1; // 如果是6,autoSizeScaleX=1.171875,autoSizeScaleY=1.17429577; // 如果是6Plus,autoSizeScaleX=1.29375,autoSizeScaleY=1.2957; -AppDelegate*laoutDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate]; + AppDelegate*laoutDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate]; if (kScreenSize.height>480) { laoutDelegate.autoSizeScaleX=kScreenSize.width/320; laoutDelegate.autoSizeScaleY=kScreenSize.height/568; @@ -290,14 +281,7 @@ if (kScreenSize.height>480) { firstLogIn=NO; [self loginAnimated:application]; - //企业版打开 - // dispatch_async(dispatch_get_main_queue(), ^{ - // if (_islaunchedByNotification==NO) { - // [self testCurrenVersion]; - // } - // }); - - + }else{ if ([isExit isEqualToString:@"1"]) { diff --git a/Ifish/Common/AppDelegate+AliPushConfig.m b/Ifish/Common/AppDelegate+AliPushConfig.m index 3d43a99..28a0936 100644 --- a/Ifish/Common/AppDelegate+AliPushConfig.m +++ b/Ifish/Common/AppDelegate+AliPushConfig.m @@ -8,6 +8,7 @@ #import "AppDelegate+AliPushConfig.h" #import +#import "IfishMessageViewController.h" static const void *NotificationCenterKey = &NotificationCenterKey; @implementation AppDelegate (AliPushConfig) - (UNUserNotificationCenter *)notificationCenter { @@ -255,8 +256,18 @@ static const void *NotificationCenterKey = &NotificationCenterKey; NSString *body = [[NSString alloc] initWithData:message.body encoding:NSUTF8StringEncoding]; NSLog(@"\n ====== Receive message title: %@, content: %@.", title, body); NSLog(@"\n ====== 当前线程 %@",[NSThread currentThread]); - [CommonUtils showAlerWithTitle:IsEmptyStr(title)?@"新消息":title withMsg:body]; - +// [CommonUtils showAlerWithTitle:IsEmptyStr(title)?@"新消息":title withMsg:body]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:IsEmptyStr(title)?@"新消息":title message:body preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + //进入消息列表页面 + IfishMessageViewController *message = [[IfishMessageViewController alloc]init]; + UIViewController *vc= (UINavigationController *)[CommonUtils appRootViewController]; + vc.hidesBottomBarWhenPushed = YES; + [vc.navigationController pushViewController:message animated:YES]; + vc.hidesBottomBarWhenPushed = NO; + }]; + [alertController addAction:alertAction]; + [[CommonUtils appRootViewController] presentViewController:alertController animated:YES completion:nil]; } #pragma mark —页面跳转(暂时不做处理) @@ -284,28 +295,16 @@ static const void *NotificationCenterKey = &NotificationCenterKey; NSString *userAction = response.actionIdentifier; - // 点击通知打开app + // 点击通知打开app(app处于后台) if ([userAction isEqualToString:UNNotificationDefaultActionIdentifier]) { NSLog(@"\n ====== User opened the notification."); // 处理iOS 10通知,并上报通知打开回执 - [self handleiOS10Notification:response.notification]; + [self handleiOS10Notification:response.notification isActive:NO]; } // 通知dismiss,category 创建时传入 UNNotificationCategoryOptionCustomDismissAction 才可以触发 if ([userAction isEqualToString:UNNotificationDismissActionIdentifier]) { NSLog(@"\n ====== User dismissed the notification."); } -// NSString *customAction1 = @"action1"; -// NSString *customAction2 = @"action2"; -// -// // 点击用户自定义Action1 -// if ([userAction isEqualToString:customAction1]) { -// NSLog(@"User custom action1."); -// } -// -// // 点击用户自定义Action2 -// if ([userAction isEqualToString:customAction2]) { -// NSLog(@"User custom action2."); -// } completionHandler(); } /** @@ -318,7 +317,7 @@ static const void *NotificationCenterKey = &NotificationCenterKey; NSLog(@"\n ====== App 处于前台时收到通知 (iOS 10+ )"); // 处理iOS 10通知,并上报通知打开回执 - [self handleiOS10Notification:notification]; + [self handleiOS10Notification:notification isActive:YES]; /* 处理完成后调用 completionHandler ,用于指示在前台显示通知的形式 @@ -345,7 +344,7 @@ static const void *NotificationCenterKey = &NotificationCenterKey; /** * 处理App 处于前台时收到通知 (iOS 10+ ) */ -- (void)handleiOS10Notification:(UNNotification *)notification { +- (void)handleiOS10Notification:(UNNotification *)notification isActive:(BOOL)isActive{ UNNotificationRequest *request = notification.request; UNNotificationContent *content = request.content; @@ -370,9 +369,29 @@ static const void *NotificationCenterKey = &NotificationCenterKey; // 通知打开回执上报 [CloudPushSDK sendNotificationAck:userInfo]; - - NSLog(@"\n ====== App 处于前台时收到通知 (iOS 10+ ) Notification, == date: %@, == title: %@, == subtitle: %@, == body: %@, == badge: %d, == extras: %@.", noticeDate, title, subtitle, body, badge, extras); - [CommonUtils showAlerWithTitle:IsEmptyStr(title)?@"新通知":title withMsg:body]; + //App处于前台 + if (isActive) { + NSLog(@"\n ====== App 处于前台时收到通知 (iOS 10+ ) Notification, == date: %@, == title: %@, == subtitle: %@, == body: %@, == badge: %d, == extras: %@.", noticeDate, title, subtitle, body, badge, extras); + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:IsEmptyStr(title)?@"新通知":title message:body preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + //进入消息列表页面 + IfishMessageViewController *message = [[IfishMessageViewController alloc]init]; + UIViewController *vc= (UINavigationController *)[CommonUtils appRootViewController]; + vc.hidesBottomBarWhenPushed = YES; + [vc.navigationController pushViewController:message animated:YES]; + vc.hidesBottomBarWhenPushed = NO; + }]; + [alertController addAction:alertAction]; + [[CommonUtils appRootViewController] presentViewController:alertController animated:YES completion:nil]; + }else{ + NSLog(@"\n ====== App 处于后台时收到通知 (iOS 10+ ) Notification,点击通知打开应用, == date: %@, == title: %@, == subtitle: %@, == body: %@, == badge: %d, == extras: %@.", noticeDate, title, subtitle, body, badge, extras); + //进入消息列表页面 + IfishMessageViewController *message = [[IfishMessageViewController alloc]init]; + UIViewController *vc= (UINavigationController *)[CommonUtils appRootViewController]; + vc.hidesBottomBarWhenPushed = YES; + [vc.navigationController pushViewController:message animated:YES]; + vc.hidesBottomBarWhenPushed = NO; + } } @@ -417,14 +436,12 @@ static const void *NotificationCenterKey = &NotificationCenterKey; */ } else if (application.applicationState == UIApplicationStateInactive) { -// // 程序处于后台 做相应的处理 -// for (NSString *tfStr in userInfo) { -// if ([tfStr isEqualToString:@"careline"]) { -// JumpViewController *_viewController = [[JumpViewController alloc]init]; -// UINavigationController *nav= (UINavigationController *)self.window.rootViewController; -// [nav pushViewController:_viewController animated:YES]; -// } -// } +// //点击通知打开app,则跳转到消息列表 +// IfishMessageViewController *message = [[IfishMessageViewController alloc]init]; +// UIViewController *vc= (UINavigationController *)[CommonUtils appRootViewController]; +// vc.hidesBottomBarWhenPushed = YES; +// [vc.navigationController pushViewController:message animated:YES]; +// vc.hidesBottomBarWhenPushed = NO; } } diff --git a/Ifish/Common/CommonUtils.m b/Ifish/Common/CommonUtils.m index b72bc05..224a1de 100644 --- a/Ifish/Common/CommonUtils.m +++ b/Ifish/Common/CommonUtils.m @@ -529,6 +529,12 @@ CGAffineTransform GetCGAffineTransformRotateAroundPoint(float centerX, float ce while (topVC.presentedViewController) { topVC = topVC.presentedViewController; } + if ([topVC isKindOfClass:[UITabBarController class]]) { + topVC = [(UITabBarController *)topVC selectedViewController]; + } + if ([topVC isKindOfClass:[UINavigationController class]]) { + topVC = [(UINavigationController *)topVC topViewController]; + } return topVC; } +(void)showAlerWithTitle:(NSString*)title withMsg:(NSString*)msg{ diff --git a/Ifish/Info.plist b/Ifish/Info.plist index 9b63f3d..f07153a 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - 9.8.5 + 9.8.8 ITSAppUsesNonExemptEncryption LSApplicationCategoryType @@ -379,11 +379,9 @@ NSLocationWhenInUseUsageDescription 为获取爱鱼奇智能硬件产品及用户的地址区域分布,以提供更好的特色服务,爱鱼奇将获取您的地址 NSMicrophoneUsageDescription - 爱鱼奇需要您的同意,才能访问麦克风 + 爱鱼奇需要您的同意,才能访问麦克风,以便于使用语音对讲等功能 NSPhotoLibraryUsageDescription 爱鱼奇需要您的同意,才能访问相册,以使用更换头像等图片上传功能 - UIApplicationExitsOnSuspend - UIBackgroundModes remote-notification diff --git a/Ifish/Utinitys/Define.h b/Ifish/Utinitys/Define.h index ca9a8e3..6513129 100644 --- a/Ifish/Utinitys/Define.h +++ b/Ifish/Utinitys/Define.h @@ -133,16 +133,15 @@ alpha:1.0] // 测试云 @"www.zhangxinyanv5.top" //#define SOCKETPORT @"www.zhangxinyanv5.top" // 云 @"app.ifish7.com" + +//正式环境 //#define SOCKETPORT @"app.ifish7.com" - -// 本地 @"192.168.61.128" -#define SOCKETPORT @"test.ifish7.com:9955" - //#define JIEKOUPORT @"https://app.ifish7.com" -//#define JIEKOUPORT @"http://test.ifish7.com:7080" +//#define JIEKOUPORTHTTP @"https://app.ifish7.com" +//测试环境 +#define SOCKETPORT @"test.ifish7.com:9955" #define JIEKOUPORT @"http://139.196.24.156:7080" #define JIEKOUPORTHTTP @"https://app.ifish7.com" - //云 @"https://app.ifish7.com" //云图片头像等地址 @"http://app.ifish7.com" //#define JIEKOUPORTHTTP @"https://app.ifish7.com" @@ -476,7 +475,7 @@ alpha:1.0] // #define getHotBarHistory [NSString stringWithFormat:@"%@/api/user/getDeviceHeaterPhsByDate.do",JIEKOUPORT] -/*=====================add V4.9.8=======================================*/ +/*=====================add V4.9.8 by wbzhan=======================================*/ //获取推送消息列表 /** pushID 本地缓存的最大的pushId,第一次无的时候则不传 diff --git a/Ifish/Utinitys/dataUnity/IfishAddGoldRuleType.h b/Ifish/Utinitys/dataUnity/IfishAddGoldRuleType.h index 8c5f45b..e23cc9f 100644 --- a/Ifish/Utinitys/dataUnity/IfishAddGoldRuleType.h +++ b/Ifish/Utinitys/dataUnity/IfishAddGoldRuleType.h @@ -41,8 +41,4 @@ #define IFISHTASK_ARR @"IfishTaskArray" #define IFISHTASK_HAVEDONEALL @"ifishTaskAllDone" -//注册成功 登录云信 -#define IFISHIMLOGINSUCSESS @"ifishIMuserLoginSucsses" - - #endif /* IfishAddGoldRuleType_h */ diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m index c095370..c3d2fac 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m @@ -445,7 +445,7 @@ }else { self.tipLabel.text = @"当月电量"; UInt64 mac = [dataContorl hexToTen:self.dataModel.electricity]; - NSString *stringTemp = [NSString stringWithFormat:@"%llukwh",mac]; + NSString *stringTemp = [NSString stringWithFormat:@"%llukwh",mac/10.0]; [self.tempLabel setAttributedText:[NSString ls_changeFontAndColor:[UIFont systemFontOfSize:15] Color:nil TotalString:stringTemp SubStringArray:@[@"kwh"]]]; if (!_switchTimer) { _switchTimer = [NSTimer timerWithTimeInterval:3.0 target:self selector:@selector(changeTemp) userInfo:nil repeats:YES]; diff --git a/Ifish/controllers/IfishTabControllers/IfishMianTabViewController.m b/Ifish/controllers/IfishTabControllers/IfishMianTabViewController.m index 714e13e..bdac196 100644 --- a/Ifish/controllers/IfishTabControllers/IfishMianTabViewController.m +++ b/Ifish/controllers/IfishTabControllers/IfishMianTabViewController.m @@ -66,16 +66,8 @@ extern BOOL launchedByNotification; }); - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imLogInnotifiy) name:IFISHIMLOGINSUCSESS object:nil]; } - --(void)imLogInnotifiy{ - //原来消息在tab 登陆界面进来时 显示badge 消息栏 消息数 UI已改暂时不需要了 如以后改回来 登陆显示badge在此处理 打开下面 - //NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount]; - //count ==0 ? (self.viewControllers[1].tabBarItem.badgeValue =nil):(self.viewControllers[1].tabBarItem.badgeValue = [NSString stringWithFormat:@"%ld",(long)count]); -} - -(void)showAdview{ IfishStartAdView *adview=[[IfishStartAdView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; @@ -106,13 +98,7 @@ extern BOOL launchedByNotification; // Dispose of any resources that can be recreated. } -(void)creatViewControllers{ - // 旧 -// NSArray*VCArr=@[@"IfishDeviceViewController", -// @"IfishMessageViewController", -// @"IfishDiscoverViewController", -// @"IfishMeViewController"]; - - + // 新v4.3前 消息在tab栏上 //NSArray*VCArr=@[@"IfishDeviceViewController", // @"IfishDiscoverViewController", @@ -197,7 +183,6 @@ extern BOOL launchedByNotification; if (launchedByNotification) { //点击通知栏启动应用 原消息在tab1 现改为0 如以后要点击通知栏在tab展示消息 或跳转相应tab 在此处理 - //self.selectedIndex = 1; self.selectedIndex = 0; launchedByNotification = NO; diff --git a/Ifish/controllers/IfishTabControllers/消息/IfishMessageViewController.m b/Ifish/controllers/IfishTabControllers/消息/IfishMessageViewController.m index 1f8db73..6b4dc6d 100644 --- a/Ifish/controllers/IfishTabControllers/消息/IfishMessageViewController.m +++ b/Ifish/controllers/IfishTabControllers/消息/IfishMessageViewController.m @@ -297,35 +297,33 @@ extern BOOL launchedByNotification; [self.dataSource addObject:oldMessageArray]; } [self.tableView reloadData]; + [self postReadMessageRequest]; } } failure:^(NSError *err) { [SVProgressHUD dismiss]; }]; } -//发送已读记录 --(void)postReadMessageRequestWithIndexPath:(NSIndexPath *)indexPath{ +//进入消息列表,则设置所有消息为已读 +-(void)postReadMessageRequest{ + UserModel*userModel=[dataContorl getUserInfo]; - PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; - if([model.isRead integerValue]==1)//未读消息 - { - NSDictionary *params = @{@"userId":userModel.userId, - @"pushId":model.pushId, + + NSDictionary *params = @{@"userId":userModel.userId, }; - [AFNOHeaderHttpTool requestWihtMethod:RequestTypePost url:Push_Message_Readed params:params success:^(id response) { + [AFNOHeaderHttpTool requestWihtMethod:RequestTypePost url:Push_Message_Readed params:params success:^(id response) { if (response) { id resault=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; NSString *result = [resault objectForKey:RESPONSE_CODE]; if ([result integerValue]==kReqSuccess) { //已读 }else{ - + } } } failure:^(NSError *err) { - - }]; - } + + }]; } //单独删除某一条消息 -(void)deleteSingleMessageWithIndex:(NSIndexPath *)indexPath{ @@ -517,8 +515,8 @@ extern BOOL launchedByNotification; dispatch_async(dispatch_get_main_queue(), ^{ - - [self postReadMessageRequestWithIndexPath:indexPath]; + //默认消息已读 +// [self postReadMessageRequestWithIndexPath:indexPath]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除该消息么" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { NSLog(@"cancel Action"); diff --git a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m index 3ff4402..320afcf 100644 --- a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m +++ b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceViewController.m @@ -98,6 +98,7 @@ Assign NSInteger messageCount;//消息个数 [self initUI]; [self showProgress]; [self addDataRequestQueue]; + [self checkNotification]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteCurDevice) name:@"DeleteCurDevice" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDevice) name:@"updateDevice" object:nil]; } @@ -134,7 +135,17 @@ Assign NSInteger messageCount;//消息个数 self.progressHud.labelText = @"加载中..."; } - +//app通过点击通知打开app,此处校验通知内容,做出相应的跳转 +-(void)checkNotification{ + //通过点击通知打开app,直接跳转到消息列表页面 + if ([AppDelegate sharedDefault].remoteNotification) { + IfishMessageViewController *message = [[IfishMessageViewController alloc]init]; + UIViewController *vc= (UINavigationController *)[CommonUtils appRootViewController]; + vc.hidesBottomBarWhenPushed = YES; + [vc.navigationController pushViewController:message animated:YES]; + vc.hidesBottomBarWhenPushed = NO; + } +} //获取未读消息个数 -(void)getMessageCount{ @@ -1591,6 +1602,8 @@ Assign NSInteger messageCount;//消息个数 #pragma mark - 导航栏消息,跳转进入消息列表 -(void)navMeaasageBtnAction{ + self.messageCount = 0; + [self setRedViewData];//刷新消息显示 // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:sessionList]; // [nav.navigationBar resetBackgroundImage]; // nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; @@ -1599,6 +1612,7 @@ Assign NSInteger messageCount;//消息个数 self.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:message animated:YES]; self.hidesBottomBarWhenPushed = NO; + } @end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m index 6e1a69f..b4f980f 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m @@ -709,7 +709,7 @@ return; } UInt64 mac = [dataContorl hexToTen:_xuanduoBack.electricity]; - NSString *stringTemp = [NSString stringWithFormat:@"%llukwh",mac]; + NSString *stringTemp = [NSString stringWithFormat:@"%llukwh",mac/10.0]; cell.templabel.font = [UIFont systemFontOfSize:37]; cell.templabel.textColor = RGB(253, 188, 63); [cell.templabel setAttributedText:[NSString ls_changeFontAndColor:[UIFont systemFontOfSize:17] Color:nil TotalString:stringTemp SubStringArray:@[@"kwh"]]]; diff --git a/Ifish/controllers/logAddRegistController/LogInViewController.m b/Ifish/controllers/logAddRegistController/LogInViewController.m index 09c14d1..6c2ddc7 100644 --- a/Ifish/controllers/logAddRegistController/LogInViewController.m +++ b/Ifish/controllers/logAddRegistController/LogInViewController.m @@ -294,7 +294,7 @@ [[IfishUserDataUnity shareDataInstance] userloginValidationSuccsess:DataDic phoneNumber:phoneNumber passward:password]; //登陆成功之后,验证当前页面devicetoken是否上送成功,如果还未上送,则重新上送devicetoken if (![[NSUserDefaults standardUserDefaults] boolForKey:is_Bind_DeviceToken]) { - UserModel *model=[[UserModel alloc] initWithDict:DataDic]; + UserModel *model=[[UserModel alloc] initWithDict:[DataDic objectForKey:@"userInfo"]]; NSDictionary *params = @{@"deviceId":[FuncUserDefault strForKey:kDeviceToken], @"userId":model.userId, @"phoneType":@"iOS"