更换阿里推送,消息页面,以及部分bug修复

This commit is contained in:
wbzhan 2019-06-15 17:44:25 +08:00
parent 1ff1ff84b1
commit 5a10dfa182
13 changed files with 97 additions and 98 deletions

View File

@ -40,6 +40,8 @@
+(NSString*)getAppVersion;
@property (strong, nonatomic) NSString *token;
@property (strong, nonatomic) NSDictionary* remoteNotification;//如果是点击通知打开的app则json有数据
//摄像头处于后台
@property (nonatomic) BOOL isGoBack;
//设备处于后台

View File

@ -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 @@
// 5autoSizeScaleX=1autoSizeScaleY=1
// 6autoSizeScaleX=1.171875autoSizeScaleY=1.17429577
// 6PlusautoSizeScaleX=1.29375autoSizeScaleY=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"]) {

View File

@ -8,6 +8,7 @@
#import "AppDelegate+AliPushConfig.h"
#import <objc/runtime.h>
#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
// appapp
if ([userAction isEqualToString:UNNotificationDefaultActionIdentifier]) {
NSLog(@"\n ====== User opened the notification.");
// iOS 10
[self handleiOS10Notification:response.notification];
[self handleiOS10Notification:response.notification isActive:NO];
}
// dismisscategory 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;
}
}

View File

@ -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{

View File

@ -70,7 +70,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.8.5</string>
<string>9.8.8</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
@ -379,11 +379,9 @@
<key>NSLocationWhenInUseUsageDescription</key>
<string>为获取爱鱼奇智能硬件产品及用户的地址区域分布,以提供更好的特色服务,爱鱼奇将获取您的地址</string>
<key>NSMicrophoneUsageDescription</key>
<string>爱鱼奇需要您的同意,才能访问麦克风</string>
<string>爱鱼奇需要您的同意,才能访问麦克风,以便于使用语音对讲等功能</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>爱鱼奇需要您的同意,才能访问相册,以使用更换头像等图片上传功能</string>
<key>UIApplicationExitsOnSuspend</key>
<false/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>

View File

@ -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

View File

@ -41,8 +41,4 @@
#define IFISHTASK_ARR @"IfishTaskArray"
#define IFISHTASK_HAVEDONEALL @"ifishTaskAllDone"
//注册成功 登录云信
#define IFISHIMLOGINSUCSESS @"ifishIMuserLoginSucsses"
#endif /* IfishAddGoldRuleType_h */

View File

@ -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];

View File

@ -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;

View File

@ -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");

View File

@ -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 = @"加载中...";
}
//appapp
-(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

View File

@ -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"]]];

View File

@ -294,7 +294,7 @@
[[IfishUserDataUnity shareDataInstance] userloginValidationSuccsess:DataDic phoneNumber:phoneNumber passward:password];
//devicetokendevicetoken
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"