You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
865 lines
37 KiB
865 lines
37 KiB
// |
|
// BaseViewController.m |
|
// ChineseAgri-businesses |
|
// |
|
// Created by ecell on 2022/6/27. |
|
// |
|
|
|
#import "BaseViewController.h" |
|
#import <AudioToolbox/AudioToolbox.h> |
|
#import "AppDelegate.h" |
|
#import "MessageViewController.h" |
|
#import "CallViewController.h" |
|
#import "ContactsViewController.h" |
|
#import "JCManager.h" |
|
#import "BRManager.h" |
|
#import "TihuManager.h" |
|
#import "MemberManagementViewController.h" |
|
|
|
@interface BaseViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate> |
|
/// 定制返回按钮 |
|
@property (nonatomic ,weak) UIButton *leftImg; |
|
|
|
@end |
|
|
|
@implementation BaseViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.zx_navLineView.hidden = YES; |
|
self.zx_navTitleFont = FontBoldADA_(16); |
|
self.view.backgroundColor = KKWhiteColorColor; |
|
self.zx_navTintColor = KKWhiteColorColor; |
|
self.zx_navBarBackgroundColor = KKMainColor; |
|
self.zx_navLeftBtn.zx_fixImageSize = ImageName_(@"icon_balck_return").size; |
|
self.zx_navItemSize = 40; |
|
self.zx_navRightBtn.zx_fixImageSize = ImageName_(@"icon_delect_1").size; |
|
self.zx_navSubRightBtn.zx_fixImageSize = ImageName_(@"icon_delect_1").size; |
|
// self.zx_navLeftBtn.backgroundColor = KKMainColor; |
|
self.view.backgroundColor = KKBackgroundGrey; |
|
[self pusMessage]; |
|
|
|
|
|
|
|
// self.zx_backBtnImageName = @"icon_balck_return"; |
|
// UIButton *leftImg = [UICommon ui_buttonSimple:CGRectMake(0, 0, 40, 40) font:Font_(0) normalColor:KKWhiteColorColor normalText:@"" click:^(id x) { |
|
// [[UICommon currentVC].navigationController popViewControllerAnimated:YES]; |
|
// }]; |
|
// [leftImg setImage:ImageName_(@"icon_white_return") forState:0]; |
|
// self.leftImg = leftImg; |
|
// self.zx_navLeftBtn.zx_customView = leftImg; |
|
// self.emptyText = @"暂无数据"; |
|
// self.buttonTitle = @"点击刷新一下"; |
|
|
|
|
|
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"KK_UPDATE_ALL_MESSAGE" object:nil] subscribeNext:^(NSNotification *x) { |
|
|
|
[self updateAllMessage]; |
|
}]; |
|
|
|
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:PUSH_type_chatGroupMessage object:nil] subscribeNext:^(NSNotification *x) { |
|
|
|
NSDictionary *dic = x.object; |
|
[self pusChatMessage:dic]; |
|
}]; |
|
} |
|
|
|
- (void)setBackImgName:(NSString *)backImgName |
|
{ |
|
_backImgName = backImgName; |
|
[self.leftImg setImage:ImageName_(@"icon_balck_return" ) forState:0]; |
|
|
|
} |
|
|
|
/// 微聊消息推送 |
|
- (void)pusChatMessage:(NSDictionary *)chatModel |
|
{ |
|
|
|
} |
|
|
|
/// 获取最新设备列表信息 |
|
- (void)updateAllMessage |
|
{ |
|
|
|
} |
|
|
|
/// 推送通知,获取最新设备电量格位置信息 |
|
- (void)updateBatteryAndLocation |
|
{ |
|
|
|
} |
|
|
|
|
|
/// 更新数据 |
|
- (void)updataNotificat |
|
{ |
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"KK_UPDATE_ALL_MESSAGE" object:nil]; |
|
} |
|
|
|
/// 空白页显示图片 |
|
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView |
|
{ |
|
|
|
if (self.ImgType == Dianziweilan) |
|
return ImageName_(@"空白电子围栏"); |
|
else if (self.ImgType == Shangkejinyong) |
|
return ImageName_(@"空白上课禁用"); |
|
else if (self.ImgType == Dianhuaben) |
|
return ImageName_(@"空白电话本"); |
|
else if (self.ImgType == Lishijilu) |
|
return ImageName_(@"空白历史记录"); |
|
else if (self.ImgType == Naozhong) |
|
return ImageName_(@"空白闹钟"); |
|
else if (self.ImgType == Xiaoxi) |
|
return ImageName_(@"空白消息"); |
|
else if (self.ImgType == Wuwang) |
|
return ImageName_(@"img_nonetwork"); |
|
else if (self.ImgType == Liaotian) |
|
return ImageName_(@"空白聊天"); |
|
else if (self.ImgType == Zhaopian) |
|
return ImageName_(@"空白照片"); |
|
else if (self.ImgType == HomeNoWhat) |
|
return ImageName_(@"temporary_binding_a_watch"); |
|
else |
|
return nil; |
|
} |
|
|
|
/// 空白页添加按钮,设置按钮文字 |
|
- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state |
|
{ |
|
NSMutableAttributedString *attributedString; |
|
if (STRINGHASVALUE(self.buttonTitle)) |
|
{ |
|
attributedString = [[NSMutableAttributedString alloc] initWithString:self.buttonTitle]; |
|
|
|
[attributedString addAttribute:NSFontAttributeName |
|
value:Font_(15) |
|
range:NSMakeRange(0, self.buttonTitle.length)]; |
|
[attributedString addAttribute:NSForegroundColorAttributeName |
|
value:[self.buttonTitleColor isKindOfClass:UIColor.class] ? self.buttonTitleColor : KKWhiteColorColor |
|
range:NSMakeRange(0, self.buttonTitle.length)]; |
|
} |
|
return attributedString; |
|
} |
|
|
|
/// 空状态描述 |
|
- ( NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView |
|
{ |
|
NSMutableAttributedString *attributedString; |
|
if (STRINGHASVALUE(self.emptyText)) |
|
{ |
|
attributedString = [[NSMutableAttributedString alloc] initWithString:self.emptyText]; |
|
|
|
[attributedString addAttribute:NSFontAttributeName |
|
value:Font_(14) |
|
range:NSMakeRange(0, self.emptyText.length)]; |
|
[attributedString addAttribute:NSForegroundColorAttributeName |
|
value:KKGrey143 |
|
range:NSMakeRange(0, self.emptyText.length)]; |
|
} |
|
return attributedString; |
|
} |
|
|
|
/// 空状态标题 |
|
- ( NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView |
|
{ |
|
NSMutableAttributedString *attributedString; |
|
if (STRINGHASVALUE(self.emptyTitle)) |
|
{ |
|
attributedString = [[NSMutableAttributedString alloc] initWithString:self.emptyTitle]; |
|
|
|
[attributedString addAttribute:NSFontAttributeName |
|
value:Font_(14) |
|
range:NSMakeRange(0, self.emptyTitle.length)]; |
|
[attributedString addAttribute:NSForegroundColorAttributeName |
|
value:KKGrey121 |
|
range:NSMakeRange(0, self.emptyTitle.length)]; |
|
} |
|
|
|
|
|
return attributedString; |
|
} |
|
|
|
/// 按钮背景图片 |
|
- (UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state |
|
{ |
|
return self.buttonImg; |
|
} |
|
|
|
/// 空白页背景颜色 |
|
- (nullable UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView |
|
{ |
|
return KKClearColor; |
|
} |
|
|
|
- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView |
|
{ |
|
scrollView.contentOffset = CGPointZero; |
|
} |
|
|
|
- (NSMutableArray *)modelListArr |
|
{ |
|
if (!_modelListArr) _modelListArr = [NSMutableArray new]; |
|
return _modelListArr; |
|
} |
|
|
|
- (void)viewWillDisappear:(BOOL)animated |
|
{ |
|
[super viewWillDisappear:animated]; |
|
[UICommon HidenLoading]; |
|
} |
|
|
|
- (void)pusMessage |
|
{ |
|
kWeakSelf(self) |
|
static BOOL isShow = NO; |
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:AccountMessageNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { |
|
|
|
static SystemSoundID alarmSoundSysID = 0; |
|
//注册声音到系统声音 |
|
NSString *path = [[NSBundle mainBundle] pathForResource:@"alarm_sound" ofType:@"caf"]; |
|
if (path) { |
|
//注册声音到系统 |
|
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path],&alarmSoundSysID); |
|
} |
|
|
|
/* |
|
//lowBattery rail sms sos photograph abnormalBodyTemperature abnormalHeartRate 提醒消息 |
|
//applicationRrecord checkedResults 关注消息 |
|
//identityTransfer identityTransfered systemUpdate 系统消息 |
|
//Recall 指令超时或者失败回调消息 |
|
//unbind 被管理员提出群组 |
|
//video 视频通话 |
|
//rejcet 视频通话被拒绝 |
|
//upHeartRate 心率 |
|
//upBodyTemperature 体温 |
|
//abnormalBodyTemperature 体温异常消息 |
|
//abnormalHeartRate 心率异常消息 |
|
*/ |
|
if(isShow){ |
|
return ; |
|
} |
|
AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate; |
|
UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController; |
|
UINavigationController *navVC = (UINavigationController*)tabBarVC.selectedViewController; |
|
//获取当前的 VC |
|
UIViewController *viewController = navVC.viewControllers.lastObject; |
|
if(!viewController){ |
|
return; |
|
} |
|
|
|
//排查其他页面的收到通知时的回调 |
|
if(![weakself isEqual: viewController]){ |
|
return; |
|
} |
|
|
|
|
|
// if([viewController isKindOfClass:[RemoteCameraViewController class]]){ |
|
// //在远程拍照页面 |
|
// return; |
|
// } |
|
|
|
|
|
NSDictionary *dic = note.object; |
|
NSDictionary *msgDic = dic[@"message"]; |
|
NSString * msgType = msgDic[@"type"]; |
|
NSString *content = GJText(@"有新消息,是否前往查看"); |
|
NSString *cancelStr = GJText(@"取消"); |
|
__block NSInteger selectIndex = 0; |
|
|
|
if(!msgType){ |
|
return ; |
|
} |
|
|
|
if([msgType isEqualToString:@"redFlower"] || [msgType isEqualToString:@"ZYTZ"] || [msgType isEqualToString:@"XYTZ"]) |
|
{ |
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"XIAOHONGHUA" object:nil]; |
|
return; |
|
} |
|
|
|
if([msgType isEqualToString:@"battery"] || [msgType isEqualToString:@"deviceNowLocation"]) |
|
{ |
|
/// 电量推送和地理位置推送 |
|
[self updateBatteryAndLocation]; |
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateBatteryAndLocation" object:nil]; |
|
return; |
|
} |
|
|
|
|
|
if([msgType isEqualToString:@"upHeartRate"] || [msgType isEqualToString:@"upBodyTemperature"]){ |
|
//清除定时的 |
|
if([msgType isEqualToString:@"upBodyTemperature"]){ |
|
[UserDefaults removeObjectForKey:[NSString stringWithFormat:@"%@&%@",TempMeasurementTimeKey,msgDic[@"imei"]]]; |
|
}else{ |
|
[UserDefaults removeObjectForKey:[NSString stringWithFormat:@"%@&%@",HeartMeasurementTimeKey,msgDic[@"imei"]]]; |
|
} |
|
|
|
if([NSStringFromClass([viewController class]) isEqualToString:@"WatchHomeViewController"] || |
|
[NSStringFromClass([viewController class]) isEqualToString:@"HAndTViewController"] ) |
|
{ |
|
//在首页或者是 心率/体温页面 刷新数据 |
|
[self viewWillAppear:YES]; |
|
return; |
|
} |
|
else |
|
{ |
|
return; |
|
} |
|
} |
|
//是否是申请的消息 |
|
// if([msgType isEqualToString:@"identityTransfer"]) |
|
// { |
|
// if([msgDic[@"openid"] isEqualToString:APIManager.sharedManager.loginModel.openid]) |
|
// { |
|
// return; |
|
// } |
|
// } |
|
int video_type = [msgDic[@"video_type"] intValue]; |
|
if([msgType isEqualToString:@"video"]){ |
|
//收到设备回拨 APP 视频通话 的视频推送 |
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
if([UIApplication sharedApplication].applicationState == UIApplicationStateActive) |
|
{ |
|
[app cleanVideoNotification]; |
|
} |
|
else |
|
{ |
|
if(video_type == 1) |
|
{ |
|
NSString * alertStr = [msgDic objectForKey:@"msgTitle"]; |
|
[app generateLocalNotificationsWithAlertStr:alertStr AndDataInfo:dic]; |
|
} |
|
} |
|
if(video_type == 1) |
|
{ |
|
//声网 |
|
//获取当前的 VC |
|
UIViewController *viewController = self.navigationController.viewControllers.lastObject; |
|
if(![viewController isKindOfClass:[CallViewController class]]) |
|
{ |
|
[weakself showCallViewWithDic:msgDic]; |
|
} |
|
return; |
|
} |
|
|
|
//MARK: 注意收到视频通话时需要 拨打过来的 imei 的Device 对象 |
|
if (video_type == 4){ |
|
//MARK:收到设备拨过来的消息 登录菊风SDK 等待连接 |
|
[self showJuphoonCallViewWithDic:msgDic WithPushDic:dic]; |
|
return; |
|
} |
|
|
|
//MARK: 收到佰锐视频来电消息 |
|
if (video_type == 5) { |
|
[self showBairuiCallViewWithDic:msgDic WithPushDic:dic]; |
|
return; |
|
} |
|
|
|
//MARK: 收到鹈鹕视频来电 |
|
if (video_type == 6) { |
|
[self showTihuCallViewWithDic:msgDic WithPushDic:dic]; |
|
return; |
|
} |
|
|
|
} |
|
if([msgType isEqualToString:@"reject"]) |
|
{ |
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
if(app.backgroudMsg){ |
|
//MARK: 取消本地推送 |
|
[app cleanVideoNotification]; |
|
[app setNormallyAlertStr:[NSString stringWithFormat:GJText(@"设备 %@ 邀请您通话未接通"),msgDic[@"imei"]] UserInfo:nil]; |
|
[[JX_GCDTimerManager sharedInstance] cancelTimerWithName:VideoTimerIdentify]; |
|
[[JX_GCDTimerManager sharedInstance] cancelTimerWithName:PlayVibrationIdentify]; |
|
app.stopVibration = YES; |
|
} |
|
} |
|
if([msgType isEqualToString:@"applicationRrecord"] |
|
|| [msgType isEqualToString:@"checkedResults"]) |
|
{ |
|
/// 关注消息需要前往成员管理查看 |
|
if ([viewController isKindOfClass:[MemberManagementViewController class]]) |
|
{ |
|
MemberManagementViewController *tempVC = (MemberManagementViewController*)viewController; |
|
[tempVC applicationRrecord]; |
|
} |
|
else |
|
{ |
|
MemberManagementViewController *vc = [MemberManagementViewController new]; |
|
vc.selectedIndex = 1; |
|
[[UICommon currentVC].navigationController pushViewController:vc animated:YES]; |
|
} |
|
return; |
|
} |
|
|
|
if([viewController isKindOfClass:[MessageViewController class]]) |
|
{ |
|
//在消息中心 |
|
MessageViewController *tempVC = (MessageViewController*)viewController; |
|
|
|
if ([msgType isEqualToString:@"identityTransfer"] |
|
|| [msgType isEqualToString:@"identityTransfered"] |
|
|| [msgType isEqualToString:@"systemUpdate"]) |
|
{ |
|
[tempVC updataSystermMessage]; |
|
} |
|
|
|
return; |
|
} |
|
if([msgType isEqualToString:@"systemUpdate"]) |
|
{ |
|
content = GJText(@"有新的系统消息,是否前往查看"); |
|
selectIndex = 1; |
|
} |
|
else if([msgType isEqualToString:@"applicationRrecord"]) |
|
{ |
|
//成员 申请 关注设备的 消息 (管理员才能收到) |
|
content = [NSString stringWithFormat:GJText(@"收到关注 %@(%@)的请求,是否前往消息中心审核"), msgDic[@"name"],msgDic[@"imei"]]; |
|
selectIndex = 1; |
|
} |
|
else if([msgType isEqualToString:@"checkedResults"]) |
|
{ //被审核结果消息 |
|
NSString *res = msgDic[@"action"]; |
|
NSString *temp = @""; |
|
if([res isEqualToString:@"agree"]){ |
|
temp = GJText(@"同意"); |
|
}else if([res isEqualToString:@"reject"]){ |
|
temp = GJText(@"拒绝"); |
|
} |
|
content = [NSString stringWithFormat:GJText(@"管理员%@你关注设备(%@)"), temp,msgDic[@"imei"]]; |
|
selectIndex = 1; |
|
|
|
|
|
isShow = YES; |
|
[self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
|
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:content AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(cancelStr) type:AlertItemTypeSystemCancel callback:^(EasyAlertView *showview, long index) { |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:^(EasyAlertView *showview, long index) { |
|
|
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV showAlertView]; |
|
[self updateAllMessage]; |
|
return; |
|
|
|
} |
|
else if([msgType isEqualToString:@"LoginOffLine"]) |
|
{ |
|
// NSLog(@"%@\n%@",msgDic[@"accesstoken"],APIManager.sharedManager.loginModel.Authorization); |
|
// if (![msgDic[@"accesstoken"] isEqualToString:APIManager.sharedManager.loginModel.Authorization]) |
|
{ |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[[[APIManager sharedManager] APGET:Logout_URL parameters:parameters resultClass:nil] subscribeNext:^(id _Nullable x) { |
|
[UICommon HidenLoading]; |
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:GJText(@"您的账号已在其他设备登录!") AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:^(EasyAlertView *showview, long index) { |
|
[[NSNotificationCenter defaultCenter] postNotificationName:sRelogin object:nil]; |
|
}]; |
|
}]; |
|
[alertV showAlertView]; |
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
return; |
|
} |
|
else if ([msgType isEqualToString:@"identityTransfer"]/// 管理员管让出去类型 |
|
|| [msgType isEqualToString:@"identityTransfered"])/// 管理员管让进来类型 |
|
{ |
|
//身份变更消息【管理员转让进来】 |
|
content = msgDic[@"body"]; |
|
//content = [NSString stringWithFormat:GJText(@"【%@】的管理员将管理员身份转让给你"),msgDic[@"name"]]; |
|
if([viewController isKindOfClass:[ContactsViewController class]]) |
|
{ |
|
ContactsViewController *VC = (ContactsViewController*)viewController; |
|
[VC GetQueryAddressList]; |
|
} |
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:content AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:nil]; |
|
}]; |
|
[alertV showAlertView]; |
|
return; |
|
// selectIndex = 2; |
|
|
|
} |
|
else if ([msgType isEqualToString:@"photograph"]) |
|
{ |
|
//是上传远程拍照的信息 |
|
// content = [NSString stringWithFormat:@"【%@】上传照片,是否前往查看",msgDic[@"name"]]; |
|
// isShow = YES; |
|
// [self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
// LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:content style:LGAlertViewStyleAlert buttonTitles:@[@"前往查看"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { |
|
// //前往远程拍照页面查看 |
|
// //先判断 当前的 imei 是否是 推送的 imei,如果不是就切换一下 主设备 |
|
// if(![cUser.cDevice.imei isEqualToString:msgDic[@"imei"]]){ |
|
// for (Device* item in cUser.myDevices) { |
|
// if([item.imei isEqualToString: msgDic[@"imei"]]){ |
|
// cUser.cDevice = item; |
|
// } |
|
// } |
|
// } |
|
// |
|
// RemoteCameraViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"RemoteCameraViewController"]; |
|
// vc.hidesBottomBarWhenPushed = YES; |
|
// AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate; |
|
// UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController; |
|
// UINavigationController *navVC = (UINavigationController*)tabBarVC.selectedViewController; |
|
// [navVC pushViewController:vc animated:YES]; |
|
// isShow = NO; |
|
// } cancelHandler:^(LGAlertView *alertView) { |
|
// isShow = NO; |
|
// [viewController viewWillAppear:YES]; |
|
// } destructiveHandler:^(LGAlertView *alertView) { |
|
// |
|
// }]; |
|
// [alertView showAnimated:YES completionHandler:nil]; |
|
return; |
|
} |
|
else if ([msgType isEqualToString:@"CostFlow"]) |
|
{ |
|
// //是查询话费流量的信息 推送 |
|
// |
|
// //在查询话费流量页面 |
|
// if([NSStringFromClass([viewController class]) isEqualToString:@"QueryCallRatesRoFlowVC"]){ |
|
// [viewController viewWillAppear:YES]; |
|
// return; |
|
// }else{ |
|
// |
|
// content = [NSString stringWithFormat:@"【%@】有新的话费流量查询消息,是否前往查看",msgDic[@"name"]]; |
|
// isShow = YES; |
|
// [self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
// LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:content style:LGAlertViewStyleAlert buttonTitles:@[@"前往查看"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { |
|
// //前往远程拍照页面查看 |
|
// //先判断 当前的 imei 是否是 推送的 imei,如果不是就切换一下 主设备 |
|
// if(![cUser.cDevice.imei isEqualToString:msgDic[@"imei"]]){ |
|
// for (Device* item in cUser.myDevices) { |
|
// if([item.imei isEqualToString: msgDic[@"imei"]]){ |
|
// cUser.cDevice = item; |
|
// } |
|
// } |
|
// } |
|
// UIViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"QueryCallRatesRoFlowVC"]; |
|
// vc.hidesBottomBarWhenPushed = YES; |
|
// AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate; |
|
// UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController; |
|
// UINavigationController *navVC = (UINavigationController*)tabBarVC.selectedViewController; |
|
// [navVC pushViewController:vc animated:YES]; |
|
// isShow = NO; |
|
// } cancelHandler:^(LGAlertView *alertView) { |
|
// isShow = NO; |
|
// [viewController viewWillAppear:YES]; |
|
// } destructiveHandler:^(LGAlertView *alertView) { |
|
// |
|
// }]; |
|
// [alertView showAnimated:YES completionHandler:nil]; |
|
return; |
|
} |
|
else if ([msgType isEqualToString:@"sos"]) |
|
{ |
|
|
|
//是 SOS 的求救信息 |
|
// content = [NSString stringWithFormat:@"【%@】触发SOS,地址:%@",msgDic[@"name"], msgDic[@"address"]]; |
|
content = [NSString stringWithFormat:GJText(@"【%@】触发SOS"),msgDic[@"name"]]; |
|
AudioServicesPlaySystemSound(alarmSoundSysID); |
|
|
|
if([msgDic valueForKey:@"msgContent"]){ |
|
content = msgDic[@"msgContent"]; |
|
} |
|
isShow = YES; |
|
[self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:content AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(cancelStr) type:AlertItemTypeSystemCancel callback:^(EasyAlertView *showview, long index) { |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:^(EasyAlertView *showview, long index) { |
|
//销毁声音 |
|
AudioServicesDisposeSystemSoundID(alarmSoundSysID); |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV showAlertView]; |
|
return; |
|
}else if ([msgType isEqualToString:@"rail"] |
|
|| [msgType isEqualToString:@"lowBattery"] |
|
|| [msgType isEqualToString:@"identityTransfered"] //身份被变更消息 |
|
|| [msgType isEqualToString:@"Recall"] //指令超时 |
|
|| [msgType isEqualToString:@"applicationOvertime"] //记录失效时间 |
|
|| [msgType isEqualToString:@"unbind"] //被管理员提出群组 |
|
|| [msgType isEqualToString:@"abnormalBodyTemperature"] //体温异常 |
|
|| [msgType isEqualToString:@"abnormalHeartRate"] //心率异常 |
|
) { |
|
|
|
|
|
if([msgType isEqualToString:@"rail"]){ |
|
//是进出安全围栏的信息 |
|
//【宝贝昵称】进入/离开安全区域【家】 |
|
NSString *res = msgDic[@"action"]; |
|
NSString *temp = @""; |
|
if([res isEqualToString:@"enter"]){ |
|
temp = @"进入"; |
|
}else if([res isEqualToString:@"leave"]){ |
|
temp = @"离开"; |
|
} |
|
content = [NSString stringWithFormat:GJText(@"【%@】%@安全区域【%@】"),msgDic[@"name"],temp,msgDic[@"railName"]]; |
|
AudioServicesPlaySystemSound(alarmSoundSysID); |
|
|
|
} |
|
else if([msgType isEqualToString:@"lowBattery"]){ |
|
//低电量的信息 |
|
//【宝贝昵称】设备低电量,当前电量8% |
|
content = [NSString stringWithFormat:GJText(@"【%@】设备低电量,当前电量%@%%"),msgDic[@"name"],msgDic[@"battery"]]; |
|
AudioServicesPlaySystemSound(alarmSoundSysID); |
|
}else if([msgType isEqualToString:@"Recall"]){ |
|
//指令超时回调 |
|
content = msgDic[@"content"]; |
|
}else if([msgType isEqualToString:@"applicationOvertime"]){ |
|
//记录失效消息 |
|
if([msgDic[@"own"] integerValue] == 1){ |
|
content = [NSString stringWithFormat:GJText(@"你申请关注【%@】设备,管理员未及时处理,申请已失效,请重新申请并联系管理员处理"),msgDic[@"name"]]; |
|
}else{ |
|
content = [NSString stringWithFormat:GJText(@"用户(%@)申请关注【%@】设备,记录未及时处理,已失效"),msgDic[@"phone"],msgDic[@"name"]]; |
|
|
|
} |
|
}else if([msgType isEqualToString:@"unbind"]){ |
|
//被管理员踢出群组 |
|
content = [NSString stringWithFormat:GJText(@"【%@】设备【%@】的管理员取消您关注设备"),msgDic[@"name"],msgDic[@"imei"]]; |
|
// 回到首页 |
|
[tabBarVC setSelectedIndex:0]; |
|
[navVC popToRootViewControllerAnimated:YES]; |
|
|
|
}else if([msgType isEqualToString:@"abnormalBodyTemperature"] //体温异常 |
|
|| [msgType isEqualToString:@"abnormalHeartRate"] //心率异常 |
|
){ |
|
AudioServicesPlaySystemSound(alarmSoundSysID); |
|
} |
|
if([msgDic valueForKey:@"msgTitle"]){ |
|
content = msgDic[@"msgTitle"]; |
|
} |
|
|
|
isShow = YES; |
|
[self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:content AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(cancelStr) type:AlertItemTypeSystemCancel callback:^(EasyAlertView *showview, long index) { |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:^(EasyAlertView *showview, long index) { |
|
//销毁声音 |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV showAlertView]; |
|
return; |
|
} |
|
|
|
isShow = YES; |
|
[self.view endEditing:YES]; //防止 LGAlertView 错乱 |
|
EasyAlertView *alertV = [EasyAlertView alertViewWithTitle:GJText(@"提示") subtitle:content AlertViewType:AlertViewTypeSystemAlert config:nil]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(cancelStr) type:AlertItemTypeSystemCancel callback:^(EasyAlertView *showview, long index) { |
|
isShow = NO; |
|
[viewController viewWillAppear:YES]; |
|
}]; |
|
}]; |
|
[alertV addAlertItem:^EasyAlertItem *{ |
|
return [EasyAlertItem itemWithTitle:GJText(@"确定") type:AlertItemTypeSystemDefault callback:^(EasyAlertView *showview, long index) { |
|
MessageViewController *vc = [MessageViewController new]; |
|
vc.selectedIndex = selectIndex; |
|
AppDelegate * appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate; |
|
UITabBarController *tabBarVC = (UITabBarController*)appDelegate.window.rootViewController; |
|
UINavigationController *navVC = (UINavigationController*)tabBarVC.selectedViewController; |
|
[navVC pushViewController:vc animated:YES]; |
|
isShow = NO; |
|
}]; |
|
}]; |
|
[alertV showAlertView]; |
|
}]; |
|
} |
|
|
|
|
|
/** |
|
MARK: 显示声网的视频通话的页面 |
|
*/ |
|
- (void)showCallViewWithDic:(NSDictionary*)dic |
|
{ |
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; |
|
CallViewController *callVC = [sb instantiateViewControllerWithIdentifier:@"CallViewController"]; |
|
callVC.modalPresentationStyle = UIModalPresentationFullScreen; |
|
callVC.appid = dic[@"appid"]; |
|
callVC.token = dic[@"token"]; |
|
@try { |
|
callVC.video_id = dic[@"video_id"]; |
|
callVC.channelID = dic[@"channelID"]; |
|
callVC.uid = dic[@"app_uid"] ; |
|
callVC.device_uid = [dic[@"uid"] integerValue]; |
|
callVC.videoSize = CGSizeMake([dic[@"distinguishability_width"] floatValue], [dic[@"distinguishability_heiger"] floatValue]) ; //AgoraVideoDimension640x360 |
|
callVC.limit_time = [dic[@"limit_time"] intValue]; |
|
callVC.wait_time = [dic[@"wait_time"] intValue]; |
|
} @catch (NSException *exception) { |
|
NSLog(@"exception.reason %@",exception.reason); |
|
} @finally { |
|
callVC.isReceiveCall = YES; |
|
[self presentViewController:callVC animated:NO completion:nil]; |
|
} |
|
|
|
} |
|
|
|
|
|
//MARK: 调起菊风视频的页面 |
|
-(void)showJuphoonCallViewWithDic:(NSDictionary*)dic WithPushDic:(NSDictionary*)pushDic{ |
|
|
|
DeviceVideoConfigModel * jhModel = [self commModel:pushDic]; |
|
|
|
//MARK: 存在 call VC 的时候忽略通知 |
|
if([JCManager shared].callViewController == nil) |
|
{ |
|
// [[JCManager shared].client setConfig:JCClientConfigServer value:@"http:cn.router.justalkcloud.com:8080"]; |
|
// [[JCManager shared].client login:jhModel.userId password:@"123"]; |
|
if(![JCManager shared].client) |
|
{ |
|
[[JCManager shared] initializeWithAPPKey:jhModel.appKey]; |
|
JCClientLoginParam* loginParam = [[JCClientLoginParam alloc] init]; |
|
loginParam.directConnectEnable = YES; |
|
[[JCManager shared].client setServerAddress:@"http:cn.router.justalkcloud.com:8080"]; |
|
[[JCManager shared].client login:APIManager.sharedManager.loginModel.openid password:@"test" loginParam:loginParam]; |
|
} |
|
[[JCManager shared].mediaDevice enableSpeaker:YES]; |
|
[JCManager shared].model = jhModel; |
|
[JCManager shared].gMianVC = self; |
|
[JCManager shared].pushData = pushDic; |
|
} |
|
//登陆成功后等待设备拨打重复拨打到APP |
|
|
|
} |
|
|
|
//MARK: 调起佰锐视频的页面 |
|
/** |
|
appkey = "A3BEE84E-9C7A-D848-85D3-90F233D9A022"; |
|
deviceName = "\U5b9d\U8d1d"; |
|
deviceVideoType = BR; |
|
"device_username" = 11529; |
|
"distinguishability_heiger" = 160; |
|
"distinguishability_width" = 120; |
|
imei = 801001234567913; |
|
"limit_time" = 300; |
|
openid = f4a0123c576d894883ddd187; |
|
password = 123456; |
|
timestamp = "1606375222.449991"; |
|
type = video; |
|
username = 11344; |
|
"video_id" = "801001234567913-201126152022"; |
|
"video_type" = 5; |
|
"wait_time" = 60; |
|
*/ |
|
-(void)showBairuiCallViewWithDic:(NSDictionary*)dic WithPushDic:(NSDictionary*)pushDic{ |
|
//需要去注册 |
|
// AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; |
|
// [app initJHWithPushDate:dic]; |
|
DeviceVideoConfigModel * brModel = [self commModel:pushDic]; |
|
|
|
if ([BRManager shared].callViewController == nil) { |
|
BRManager * manager = [BRManager shared]; |
|
manager.callType = brModel.call_type; |
|
if (![manager isUserLogin]) { |
|
[manager login:brModel.userId nick: APIManager.sharedManager.deviceModel.name]; |
|
NSLog(@"====佰锐视频推送用户->登录===="); |
|
} else { |
|
NSLog(@"====佰锐视频推送用户->已经登录="); |
|
} |
|
|
|
[BRManager shared].brModel = brModel; |
|
} |
|
|
|
//登陆成功后等待设备拨打重复拨打到APP |
|
} |
|
|
|
-(void)showTihuCallViewWithDic:(NSDictionary*)dic WithPushDic:(NSDictionary*)pushDic{ |
|
|
|
DeviceVideoConfigModel *thModel = [self commModel:pushDic]; |
|
|
|
if ([TihuManager shared].callViewController == nil) { |
|
if (![[TihuManager shared] isUserLogin]) { |
|
[[TihuManager shared] initialize]; |
|
[TihuManager shared].gMianVC = self; |
|
[[TihuManager shared] login:thModel.openid pwd:@"123456"]; |
|
|
|
NSLog(@"鹈鹕账号是:%@", APIManager.sharedManager.loginModel.openid); |
|
} else { |
|
NSLog(@"====>鹈鹕视频账号已经登录"); |
|
} |
|
[TihuManager shared].thModel = thModel; |
|
} |
|
} |
|
|
|
|
|
- (DeviceVideoConfigModel *)commModel:(NSDictionary *)dic |
|
{ |
|
dic = dic[@"message"]; |
|
DeviceVideoConfigModel *model = [DeviceVideoConfigModel new]; |
|
model.width = [dic[@"distinguishability_width"] integerValue]; |
|
model.height = [dic[@"distinguishability_heiger"] integerValue]; |
|
model.appKey = dic[@"appkey"]; |
|
model.userId = dic[@"username"]; |
|
model.videoId = dic[@"video_id"]; |
|
model.oneCallTime = [dic[@"wait_time"] integerValue]; |
|
model.allCallTime = [dic[@"limit_time"] integerValue]; |
|
model.deviceUserName = dic[@"device_username"]; |
|
model.openid = F(@"%@", dic[@"openid"]); |
|
NSInteger videoType = 1; |
|
if ([dic[@"video_type"] integerValue] == 5) /// 佰锐 |
|
videoType = 3; |
|
else if ([dic[@"video_type"] integerValue] == 1) /// 声网 |
|
videoType = 2; |
|
else if ([dic[@"video_type"] integerValue] == 6) /// 鹈鹕 |
|
videoType = 4; |
|
else if ([dic[@"video_type"] integerValue] == 4) /// 菊风 |
|
videoType = 1; |
|
|
|
model.videoType = videoType; |
|
model.call_type = [dic[@"type"] isEqualToString:@"video"] ? 0 : 1; |
|
return model; |
|
} |
|
|
|
-(void)viewDidDisappear:(BOOL)animated{ |
|
[super viewDidDisappear:animated]; |
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:AccountMessageNotification object:nil]; |
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:PUSH_type_chatGroupDisband object:nil]; |
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:PUSH_type_chatGroupRemove object:nil]; |
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateBatteryAndLocation" object:nil]; |
|
} |
|
|
|
/* |
|
#pragma mark - Navigation |
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation |
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
|
// Get the new view controller using [segue destinationViewController]. |
|
// Pass the selected object to the new view controller. |
|
} |
|
*/ |
|
|
|
@end
|
|
|