SceneDelegate.m 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143
  1. //
  2. // SceneDelegate.m
  3. // Private-X
  4. //
  5. // Created by 余衡武 on 2021/12/8.
  6. //
  7. #import "SceneDelegate.h"
  8. #import "HWWebViewController.h"
  9. #import "CalculatorViewController.h"
  10. #import "SetUsePWDViewController.h"
  11. #import "GuideViewController.h"
  12. #import "BaseNavigationController.h"
  13. #import "MySetViewController.h"
  14. #import "SafeForKey.h"
  15. #import "TipsQRCodeViewController.h"
  16. #import "SetPWDFirstViewController.h"
  17. #import "connectDeviceManager.h"
  18. #import "inputPWDViewController.h"
  19. #import "customLaunchView.h"
  20. #import "RSATool.h"
  21. #import "forgetPwdViewController.h"
  22. #import "TipsQRCodeForChangeDeviceViewController.h"
  23. #import "AFNetworkReachabilityManager.h"
  24. #import "ComontAlretViewController.h"
  25. #import "uploadFileManager.h"
  26. //#import "downloadManager.h"
  27. #import "nasDownloadFileManager.h"
  28. //#import "backupsFileManager.h"
  29. #import "nasBackupsManager.h"
  30. #import "iPhone.h"
  31. #import <WXApi.h>
  32. #import <TencentOpenAPI/QQApiInterface.h>
  33. #import <TencentOpenAPI/TencentOAuth.h>
  34. #import "NASMsgModel.h"
  35. #import "queryOneShareModel.h"
  36. #import "boxSaveFileManager.h"
  37. #import "boxDownloadFileManager.h"
  38. #import "NASViewController.h"
  39. #import "cloudPhoneViewController.h"
  40. #import "mineViewController.h"
  41. #import "lastFileManager.h"
  42. #import "customDownloadManager.h"
  43. #import "audioPlayListManager.h"
  44. #import "QRCodeScanForChangeDeviceViewController.h"
  45. #import "customToastVew.h"
  46. #import "DFPlayer.h"
  47. #import "UIInterface+HXRotation.h"
  48. #import "imageDetailsScrollViewController.h"
  49. #import "videoPlayByAVPlayerViewController.h"
  50. #import "pingManager.h"
  51. #import "webRtcPlayerViewController.h"
  52. #import "webRtcPingManager.h"
  53. #import "imageVersionRenewTipView.h"
  54. #import "HWVersionModel.h"
  55. #import "HaveNewVersionView.h"
  56. #import "newerGuideView.h"
  57. #import "CustomerWebViewController.h"
  58. #import "noticeModel.h"
  59. #import "HaveNoticeView.h"
  60. #import "UpgradeInfoModel.h"
  61. #import "imageVersionUpdateDoneView.h"
  62. #import "imageVersionUpdateFailView.h"
  63. #import "LoginType1ViewController.h"
  64. #import "privacyModeTipViewController.h"
  65. #import "previewFileAndFolderViewController.h"
  66. @interface SceneDelegate ()<SetUsePWDViewControllerDelegate,GuideViewControllerDelegate,UITabBarControllerDelegate>
  67. {
  68. imageVersionRenewTipView * RenewTipView;
  69. imageVersionUpdateDoneView* imageVersionUpdateDoneV;
  70. imageVersionUpdateFailView* imageVersionUpdateFailV;
  71. }
  72. @property (nonatomic,strong)UpgradeInfoModel*otaUpgradeInfoModel;
  73. @property(nonatomic, strong) CalculatorViewController *calculatorVC;
  74. @property(nonatomic, strong) HWWebViewController *webVC;
  75. @property(nonatomic, strong) inputPWDViewController *inputVC;
  76. @property(nonatomic, strong) customLaunchView *customLaunchV;//
  77. @property(nonatomic, strong) BaseNavigationController *preRootPlayerNav;
  78. @property(nonatomic, assign) bool isQRCodeType;//第一次 扫码进来的
  79. //@property(nonatomic, assign) bool isNeedToShowSecretKey;//扫码进来的SN 没有密码 则需要显示秘钥
  80. @property (nonatomic, assign) BOOL isLoginAgainType;// 单点登录 点重新登录进来的
  81. @property (nonatomic, assign) BOOL isNeedToStopWork;// 无网络报错
  82. @property(nonatomic, copy) NSString *getShareStr;//拿到分享的字符串
  83. @property (nonatomic, assign) BOOL isFirstOpenInLaunch;//启动页停两秒
  84. //冷启动分享跳入用
  85. @property(nonatomic, strong) UISceneSession *session;
  86. @property(nonatomic, strong) UISceneConnectionOptions *connectionOptions;
  87. @end
  88. @implementation SceneDelegate
  89. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
  90. HLog(@"willConnectToSession")
  91. if (scene) {
  92. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(guideOk:) name:GuideOkNotification object:nil];
  93. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLockViewFun:) name:lockBypwdNotification object:nil];
  94. //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setPwdVCFun:) name:setPwdNotification object:nil];
  95. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdFun:) name:forgetPwdNotification object:nil];
  96. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdBackFun:) name:forgetPwdBackNotification object:nil];
  97. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forgetPwdDidSetPwdFun:) name:forgetPwdDidSetNotification object:nil];
  98. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceFun:) name:scanChangeDeviceNotification object:nil];
  99. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scanChangeDeviceBackFun:) name:scanChangeDeviceBackNotification object:nil];
  100. UIWindowScene *windowScene = (UIWindowScene *)scene;
  101. self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
  102. self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
  103. _isFirstOpenInLaunch = YES;
  104. // 初始化数据库
  105. [self initBrowserWindow];
  106. //查询当前的最近webrtc机房
  107. NSDictionary *dict = [HWDataManager getObjectWithKey:@"Const_best_webRtc_IPRoom"];
  108. if(dict){
  109. webrtcServerModel *model = [[webrtcServerModel alloc] initWithDictionary:dict error:nil];
  110. if(model && model.turnIp){
  111. ksharedAppDelegate.bestWebrtcServerModel = model;
  112. }
  113. }
  114. // 加载主页面
  115. [self enterMainVCFromScene];
  116. //
  117. [self reportVersionInfoFun];
  118. [self.window makeKeyAndVisible];
  119. ksharedAppDelegate.window = self.window;
  120. //冷启动
  121. if(connectionOptions.URLContexts != nil){
  122. _session = session;
  123. _connectionOptions = connectionOptions;
  124. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  125. // mainBlock(^{
  126. // [self scene:scene openURLContexts:connectionOptions.URLContexts];
  127. // });
  128. // });
  129. }
  130. }
  131. }
  132. /** 主界面 - 内部使用 */
  133. - (void)enterMainVCFromScene {
  134. // ConnectTestViewController *qrCodeVCNav = [[ConnectTestViewController alloc] init];
  135. // self.window.rootViewController = qrCodeVCNav;
  136. // return;/*临时测试*/
  137. if(_isNeedToStopWork){
  138. return;
  139. }
  140. /*先判断本地有无设备 无设备时需要先扫码添加设备*/
  141. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  142. if (!deviceDict || ![[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  143. //默认显示最近文件
  144. [HWDataManager setBoolWithKey:Const_last_file_show value:YES];
  145. /*扫码界面*/
  146. //TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  147. LoginType1ViewController *qrCodeVC = [[LoginType1ViewController alloc] init];
  148. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  149. self.window.rootViewController = qrCodeVCNav;
  150. _isQRCodeType = YES;
  151. return;
  152. }
  153. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  154. // GuideViewController
  155. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  156. if (haveGuide) {
  157. ;
  158. }else {
  159. GuideViewController *guiDeVC = [[GuideViewController alloc] init];
  160. guiDeVC.delegate = self;
  161. guiDeVC.sn = SNStr;
  162. self.window.rootViewController = guiDeVC;
  163. return;
  164. }
  165. //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  166. #ifdef developJSQ
  167. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  168. #else
  169. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  170. #endif
  171. //添加默认启动图片
  172. if(!_customLaunchV && maskModel == 0){
  173. _customLaunchV = [[customLaunchView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  174. [self.window addSubview:_customLaunchV];
  175. }
  176. if(maskModel == 0 && _isFirstOpenInLaunch){
  177. //20240612 产品觉得 启动页太快了 要停两秒
  178. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  179. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  180. {
  181. [[iToast makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)] show];
  182. customToastVew *toastview = [customToastVew makeText:NSLocalizedString(@"phone_network_fail_Tips",nil)];
  183. [toastview show];
  184. [self->_customLaunchV addSubview:toastview];
  185. return;
  186. }
  187. [self getDeviceMsgInMainVCWith:deviceDict];
  188. });
  189. _isFirstOpenInLaunch = NO;
  190. }
  191. else{
  192. //延时等网络状态
  193. if(_isFirstOpenInLaunch){
  194. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  195. [self getDeviceMsgInMainVCWith:deviceDict];
  196. });
  197. _isFirstOpenInLaunch = NO;
  198. }
  199. else{
  200. [self getDeviceMsgInMainVCWith:deviceDict];
  201. }
  202. }
  203. //[self showNetErrorAlertType2Fun];
  204. }
  205. - (void)getDeviceMsgInMainVCWith:(NSDictionary*)deviceDict
  206. {
  207. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable)
  208. {
  209. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  210. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  211. if(!isPrivacyMode && maskModel == 0){
  212. return;
  213. }
  214. [self initMainTabbarFun];
  215. [self showCalculatorVC];
  216. return;
  217. }
  218. KWeakSelf
  219. //有设备了先去做链接准备 // 80bec9c5
  220. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  221. NSString *sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
  222. if(SNStr && !sdnId){
  223. //瑞云方案
  224. // [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  225. //
  226. // if(didSuc == 0){
  227. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  228. // mainBlock(^{
  229. // [weakSelf showNetErrorAlertFun];
  230. // [weakSelf enterMainVCFromSceneSecondStepFun];
  231. // });
  232. // });
  233. // }
  234. // else if(didSuc == 2
  235. // ||didSuc == 201
  236. // ||didSuc == 202){
  237. // [weakSelf gotoScanAginByThridMsgErrorFun:didSuc];
  238. // }
  239. // else{
  240. // [weakSelf enterMainVCFromSceneSecondStepFun];
  241. // }
  242. //
  243. // }];
  244. //webrtc方案
  245. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  246. [paraDict setValue:SNStr forKey:@"sn"];
  247. KWeakSelf
  248. [[netWorkManager shareInstance] CommonGetWithCallBackCode:getThirdIdBySn Parameters:paraDict success:^(id _Nonnull responseObject) {
  249. DeviceThirdIdModel *model = [[DeviceThirdIdModel alloc] initWithDictionary:responseObject error:nil];
  250. if(model.status == 0
  251. && model.data)
  252. {//根据SN 获取到正确的信息
  253. ksharedAppDelegate.DeviceThirdIdMod = model;
  254. NSString*desPwdstr = [RSATool AES128Decrypt:model.data.password key:AESCODEKEEYY];
  255. /*密码保持在本地*/
  256. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  257. NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:deviceDict];
  258. [dict setObject:desPwdstr forKey:Const_Have_Add_Device_PWD];
  259. NSString *sdnid = model.data.sdnId;
  260. if(sdnid){
  261. [dict setObject:sdnid forKey:Const_Have_Add_Device_sdnid];
  262. }
  263. [HWDataManager setObjectWithKey:Const_Have_Add_Device_Privacy_Mode value:[NSNumber numberWithBool:model.data.isPrivacyMode]];
  264. [HWDataManager setObjectWithKey:Const_Have_Add_Device value:dict];
  265. [weakSelf enterMainVCFromSceneSecondStepFun];;
  266. //ping看上是否为内网情况
  267. [[pingManager shareManager] startPingDeviceIpFun];
  268. //获取webrtc相关信息
  269. [weakSelf queryWebRtcMsgFun];
  270. }
  271. else{
  272. //if(model.status == 201||model.status == 202 || model.status ==2){}
  273. [weakSelf gotoScanAginByThridMsgErrorFun:model.status];
  274. }
  275. } failure:^(NSError * _Nonnull error) {
  276. HLog("网络报错");
  277. mainBlock(^{
  278. [weakSelf showNetErrorAlertFun];
  279. [weakSelf enterMainVCFromSceneSecondStepFun];
  280. });
  281. }];
  282. }
  283. else{
  284. //ping看上是否为内网情况
  285. [[pingManager shareManager] startPingDeviceIpFun];
  286. if (!ksharedAppDelegate.DeviceWebRtcMsgMod) {
  287. //获取webrtc相关信息
  288. [weakSelf queryWebRtcMsgFun];
  289. }
  290. [self enterMainVCFromSceneSecondStepFun];
  291. }
  292. }
  293. #pragma mark 获取webrct 的链接信息
  294. -(void)queryWebRtcMsgFun
  295. {
  296. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  297. KWeakSelf
  298. [[netWorkManager shareInstance] CommonPostCallBackCode:webrctQueryByClient Parameters:paraDict success:^(id _Nonnull responseObject){
  299. webRtcMsgModel *curModel = [[webRtcMsgModel alloc] initWithDictionary:responseObject error:nil];
  300. if(curModel && curModel.status == 0){
  301. ksharedAppDelegate.DeviceWebRtcMsgMod = curModel;
  302. if(!ksharedAppDelegate.bestWebrtcServerModel){
  303. webrtcServerModel *model = curModel.data.webrtcServerList.firstObject;
  304. ksharedAppDelegate.bestWebrtcServerModel = model;
  305. }
  306. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  307. [[webRtcPingManager shareManager] startPingFun];
  308. }
  309. else
  310. {
  311. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  312. [weakSelf queryWebRtcMsgFun];
  313. });
  314. }
  315. } failure:^(NSError * _Nonnull error) {
  316. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  317. [weakSelf queryWebRtcMsgFun];
  318. });
  319. }];
  320. }
  321. - (void)enterMainVCFromSceneSecondStepFun
  322. {
  323. //确保通过SN号拿到密码了
  324. //非扫码进入 进入到这里很可能还没联网拿到设备最新信息
  325. if(!ksharedAppDelegate.DeviceThirdIdMod
  326. &&!ksharedAppDelegate.DeviceWebRtcMsgMod){
  327. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  328. mainBlock(^{
  329. [self enterMainVCFromScene];
  330. });
  331. });
  332. return;
  333. }
  334. //是否已经有密码了 有就是输入密码 没有就是设置密码
  335. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  336. NSString * sdnId = ksharedAppDelegate.DeviceThirdIdMod.data.sdnId;
  337. if(!sdnId && !ksharedAppDelegate.DeviceWebRtcMsgMod){
  338. HLog(@"没有拿到 --sdnId:%@ --- DeviceWebRtcMsgMod:%@",sdnId,ksharedAppDelegate.DeviceWebRtcMsgMod);
  339. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  340. mainBlock(^{
  341. [self enterMainVCFromScene];
  342. });
  343. });
  344. return;
  345. }
  346. if(_customLaunchV){
  347. [_customLaunchV removeFromSuperview];
  348. _customLaunchV = nil;
  349. }
  350. if(curPwd && curPwd.length > 0){
  351. /*设置密码*/
  352. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  353. // BaseNavigationController *nextVCNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  354. // self.window.rootViewController = nextVCNav;
  355. }
  356. else{
  357. //1、重启、恢复出厂设备、首次设置密码 3个情况下8分钟之内不弹
  358. long seconds = [iTools getNowTimeStamp];
  359. NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
  360. if(secondsNum){
  361. [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type2_BoxHeartbeat") value:secondsNum];
  362. }
  363. /*没有设置密码*/
  364. SetPWDFirstViewController *qrCodeVC = [[SetPWDFirstViewController alloc] init];
  365. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  366. self.window.rootViewController = qrCodeVCNav;
  367. return;
  368. }
  369. //下载配置先处理
  370. [boxDownloadFileManager shareInstance];
  371. [lastFileManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  372. [audioPlayListManager shareManager].uid = ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  373. //获取NAS相关信息
  374. [self getNASMsgFun];
  375. [self initMainTabbarFun];
  376. self.isLoginAgainType = NO;
  377. __block BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  378. //KWeakSelf
  379. if(!_isQRCodeType){
  380. if(isPrivacyMode)
  381. {
  382. [self showCalculatorVC];
  383. }
  384. else{
  385. [self HandleEnterNotPrivacyModeFun];
  386. ksharedAppDelegate.isFirstInputPwdDone = YES;
  387. //playerRootVC.isPwdVCShow = NO;
  388. //[playerRootVC setShowImgAndVoiceTypeFun:YES];
  389. //[weakSelf shareAwakenAppBy:weakSelf.getShareStr];
  390. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  391. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  392. });
  393. if(self->_session && self->_connectionOptions){
  394. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  395. }
  396. }
  397. //_isQRCodeType = NO;
  398. }
  399. else{
  400. if(isPrivacyMode)
  401. {
  402. [self showCalculatorVC];
  403. }
  404. else{
  405. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  406. ksharedAppDelegate.isFirstInputPwdDone = YES;
  407. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  408. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  409. });
  410. }
  411. }
  412. _isQRCodeType = NO;
  413. //数据埋点
  414. [[netWorkManager shareInstance] DataEmbeddingPointBy:1 withEventValue:@"Nas"];
  415. }
  416. #pragma mark 1.4.1 新增tabbar
  417. - (void)initMainTabbarFun
  418. {
  419. UITabBarController *tabBarController = [[UITabBarController alloc] init];
  420. tabBarController.delegate = self;
  421. NASViewController *NASVC = [[NASViewController alloc] init];
  422. BaseNavigationController *NasNav = [[BaseNavigationController alloc] initWithRootViewController:NASVC];
  423. cloudPhoneViewController *cloudVC = [[cloudPhoneViewController alloc] init];
  424. BaseNavigationController *cloudPhoneNav = [[BaseNavigationController alloc] initWithRootViewController:cloudVC];
  425. previewFileAndFolderViewController *fileVC = [[previewFileAndFolderViewController alloc] init];
  426. BaseNavigationController *fileNav = [[BaseNavigationController alloc] initWithRootViewController:fileVC];
  427. mineViewController *mineVC = [[mineViewController alloc] init];
  428. BaseNavigationController *mineNav = [[BaseNavigationController alloc] initWithRootViewController:mineVC];
  429. NSString*phoneTitle = NSLocalizedString(@"tabbar_cloud_phone",nil);
  430. NSString*myTitle = NSLocalizedString(@"tabbar_my_title",nil);
  431. NSString*fileTitle = NSLocalizedString(@"my_set_no_file",nil);
  432. //NSArray *viewControllers = @[NasNav, cloudPhoneNav,mineNav]; // 添加更多视图控制器
  433. NSArray *viewControllers = @[NasNav,fileNav,mineNav]; // 添加更多视图控制器
  434. NSArray *titleArr = @[@"NAS",fileTitle,myTitle];
  435. NSArray *imageNArr = @[@"tabbar_nas_N", @"tabbar_file_N",@"tabbar_my_N"];
  436. NSArray *imageHArr = @[@"tabbar_nas_H", @"tabbar_file_H",@"tabbar_my_H"];
  437. if(ksharedAppDelegate.DeviceThirdIdMod
  438. && ![ksharedAppDelegate.DeviceThirdIdMod.data.changeSn isEqualToString:@"0333933700223110016962"]){
  439. titleArr = @[@"NAS",phoneTitle,myTitle];
  440. imageNArr = @[@"tabbar_nas_N", @"my_device_NO",@"tabbar_my_N"];
  441. imageHArr = @[@"tabbar_nas_H", @"my_device_ok",@"tabbar_my_H"];
  442. viewControllers = @[NasNav,cloudPhoneNav,mineNav];
  443. }
  444. tabBarController.viewControllers = viewControllers;
  445. for (int i=0; i<viewControllers.count; i++) {
  446. UITabBarItem * tabBarItem = [UITabBarItem new];
  447. tabBarItem.title = titleArr[i];
  448. tabBarItem.selectedImage = [[UIImage imageNamed:imageHArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  449. tabBarItem.image = [[UIImage imageNamed:imageNArr[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  450. UIViewController *curVC = viewControllers[i];
  451. curVC.tabBarItem = tabBarItem;
  452. }
  453. //tabBarController.tabBar.barTintColor = [UIColor hwColor:@"#F6F8FA"]; // 设置标签栏背景色
  454. tabBarController.tabBar.tintColor = [UIColor hwColor:@"#01B7EA"]; // 设置选中标签项的颜色
  455. tabBarController.tabBar.unselectedItemTintColor = [UIColor hwColor:@"#7C8196"]; // 设置未选中标签项的颜色
  456. tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
  457. // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor hwColor:@"#01B7EA"],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateSelected];
  458. // //[UIColor hwColor:@"#7C8196"]
  459. // [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:12.0],NSFontAttributeName,nil] forState:UIControlStateNormal];
  460. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  461. if(haveOpenMask){
  462. //非隐私模式 直接进入推拉流页
  463. if(ksharedAppDelegate.DeviceThirdIdMod && !ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode){
  464. ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType = YES;
  465. [cloudVC queryWebRtcMsgFun:YES];
  466. }
  467. else{
  468. ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType = YES;
  469. }
  470. tabBarController.selectedIndex = 1;
  471. }
  472. ksharedAppDelegate.mainTabBar = tabBarController;
  473. self.window.rootViewController = tabBarController;
  474. [self.window makeKeyAndVisible];
  475. CGFloat second = 1.0;
  476. //BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  477. if(haveOpenMask){
  478. second = 3;
  479. }
  480. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  481. [self beginShowAlertFun];
  482. });
  483. }
  484. #pragma mark 处理进来是非隐私模式的情况
  485. - (void)HandleEnterNotPrivacyModeFun
  486. {
  487. #ifdef developJSQ
  488. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  489. #else
  490. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  491. #endif
  492. if (maskModel != 0){
  493. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  494. [iTools lc_setAlternateIconName:@"AppIcon1"];
  495. }
  496. }
  497. - (void)setPwdOk{
  498. [self enterMainVCFromScene];
  499. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  500. //
  501. // if (dataArray.count == 0) { // 浏览器没有窗口
  502. // // 加载首页
  503. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  504. // vc.webUrl = Const_HomeUrl;
  505. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  506. // self.window.rootViewController = nvc;
  507. //
  508. // }else {
  509. // // 浏览器当前窗口索引ID
  510. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  511. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  512. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  513. // BaseModel *model = finfAlls.firstObject;
  514. //
  515. // // 加载网页
  516. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  517. // vc.webUrl = model.webUrl;
  518. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  519. // self.window.rootViewController = nvc;
  520. // }
  521. }
  522. /** 登录界面 - 外部使用*/
  523. + (void)enterLoginVC {
  524. // SetPWDViewController *vc = [[SetPWDViewController alloc] init];
  525. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  526. // UIWindow *keyWindow = [iTools getKeyWindow];
  527. // keyWindow.rootViewController = nvc;
  528. }
  529. /** 主界面 - 外部使用 */
  530. + (void)enterMainVC {
  531. // AlbumHomeViewController *vc = [[AlbumHomeViewController alloc] init];
  532. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  533. // UIWindow *keyWindow = [iTools getKeyWindow];
  534. // keyWindow.rootViewController = nvc;
  535. }
  536. - (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  537. HLog(@"sceneDidDisconnect");
  538. //[[connectDeviceManager shareInstance] disconnect];
  539. }
  540. - (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  541. HLog(@"sceneDidBecomeActive")
  542. }
  543. - (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  544. HLog(@"sceneWillResignActive")
  545. }
  546. - (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  547. HLog(@"sceneWillEnterForeground")
  548. [self beginShowAlertFun];
  549. }
  550. - (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
  551. HLog(@"sceneDidEnterBackground")
  552. ksharedAppDelegate.didShowBoxHeartbeatAlertType = NO;
  553. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  554. if(ksharedAppDelegate.DeviceThirdIdMod){
  555. isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  556. }
  557. if(isPrivacyMode){//隐私模式 需要弹密码框 转竖屏
  558. BOOL isNeeddelayedType = NO;
  559. //这里强制竖屏 处理图片详情 和视频详情的横屏情况
  560. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  561. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  562. NSArray* vcArr = mainNav.viewControllers;
  563. if(vcArr.count >= 2){
  564. UIViewController *curVC = vcArr.lastObject;
  565. if([curVC isKindOfClass:[webRtcPlayerViewController class]]){
  566. webRtcPlayerViewController* vc = (webRtcPlayerViewController*)curVC;
  567. if(vc.isLan){
  568. ksharedAppDelegate.needToPushWebRtcVCType = YES;
  569. [vc exitCloudPhoneFun];
  570. }
  571. }
  572. else if([curVC isKindOfClass:[imageDetailsScrollViewController class]]
  573. ||[curVC isKindOfClass:[videoPlayByAVPlayerViewController class]]){
  574. //切换到竖屏
  575. ksharedAppDelegate.supportScreenRotateType = YES;
  576. [curVC hx_rotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
  577. //ksharedAppDelegate.supportScreenRotateType = NO;
  578. isNeeddelayedType = YES;
  579. HLog(@"sceneDidEnterBackground 旋转屏幕为竖屏")
  580. }
  581. }
  582. }
  583. [self showCalculatorVC];
  584. }
  585. }
  586. - (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
  587. HLog(@"scene continueUserActivity")
  588. if([TencentOAuth CanHandleUniversalLink:userActivity.webpageURL]){
  589. [TencentOAuth HandleUniversalLink:userActivity.webpageURL];
  590. }
  591. else{
  592. [WXApi handleOpenUniversalLink:userActivity delegate:self];
  593. }
  594. }
  595. - (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  596. HLog(@"scene openURLContexts")
  597. NSEnumerator *enumerator = [URLContexts objectEnumerator];
  598. UIOpenURLContext *context;
  599. while (context = [enumerator nextObject]) {
  600. NSLog(@"context.URL =====%@",context.URL);
  601. //openprivacyxapp://page?param1=value1&param2=value2
  602. NSString *curStr = context.URL.absoluteString;
  603. if([curStr rangeOfString:@"openprivacyxapp://page"].location != NSNotFound){
  604. _getShareStr = curStr;
  605. [self delayedHandlShareAwakenAppBy:curStr];
  606. break;
  607. }
  608. else{
  609. [WXApi handleOpenURL:context.URL delegate:self];
  610. }
  611. //NSLog(@"context.options.sourceApplication ===== %@",context.options.sourceApplication);
  612. }
  613. _session = nil;
  614. _connectionOptions = nil;
  615. }
  616. - (void)delayedHandlShareAwakenAppBy:(NSString*)curStr{
  617. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  618. [self shareAwakenAppBy:curStr];
  619. });
  620. }
  621. #pragma mark 初始化数据库-DB_BrowserWindows_TableName
  622. - (void)initBrowserWindow {
  623. // 浏览器当前所有窗口
  624. NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  625. // 浏览器当前窗口索引ID
  626. NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  627. NSString *IDValue = [NSString stringWithFormat:@"%ld", ID];
  628. NSString *where = [NSString stringWithFormat:@"where %@=%@",bg_sqlKey(@"ID"),bg_sqlValue(IDValue)];
  629. NSArray *modelArr = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  630. if (dataArray.count == 0) { // 浏览器没有窗口
  631. BaseModel *model = [[BaseModel alloc] init];
  632. model.ID = 0;
  633. model.name = @"主页";
  634. // model.iconFile = imageUrl;
  635. model.webUrl = Const_HomeUrl;
  636. // 写入数据库
  637. model.bg_tableName = DB_BrowserWindows_TableName;
  638. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  639. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  640. }];
  641. // 浏览器当前窗口索引ID
  642. [HWDataManager setIntegerWithKey:BrowserWindowsCurrentID value:0];
  643. }else if (modelArr.count == 0) { // 新建窗口
  644. BaseModel *model = [[BaseModel alloc] init];
  645. model.ID = ID;
  646. model.name = @"主页";
  647. // model.iconFile = imageUrl;
  648. model.webUrl = Const_HomeUrl;
  649. // 写入数据库
  650. model.bg_tableName = DB_BrowserWindows_TableName;
  651. [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  652. HLog(@"BaseModel写入:%@", isSuccess ? @"成功":@"失败");
  653. }];
  654. }else { // 更新窗口数据
  655. // 浏览器当前窗口索引ID
  656. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  657. //
  658. // BaseModel *model = [[BaseModel alloc] init];
  659. // model.ID = ID;
  660. // model.name = @"主页";
  661. //// model.iconFile = imageUrl;
  662. // model.webUrl = Const_HomeUrl;
  663. //
  664. // // 更新数据库
  665. // model.bg_tableName = DB_BrowserWindows_TableName;
  666. // [model bg_saveOrUpdateAsync:^(BOOL isSuccess) {
  667. // HLog(@"BaseModel更新: %@", isSuccess ? @"成功":@"失败");
  668. // }];
  669. }
  670. }
  671. #pragma mark 获取当前屏幕的截图
  672. //- (UIImage *)getScreenShotImage {
  673. // CGSize size = [UIScreen mainScreen].bounds.size;
  674. // CGFloat scale = [UIScreen mainScreen].scale;
  675. // UIGraphicsBeginImageContextWithOptions(size, YES, scale);
  676. // [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
  677. // UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
  678. // UIGraphicsEndImageContext();
  679. // return image;
  680. //}
  681. #pragma mark 计算器伪装视图
  682. /*CalculatorViewController*/
  683. - (void)showCalculatorVC{
  684. HLog(@"showCalculatorVC 处理密码框弹出")
  685. // if(SCREEN_W > SCREEN_H){
  686. // HLog(@"showCalculatorVC 屏幕还是横屏状态")
  687. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  688. // [self showCalculatorVC];
  689. // });
  690. // return;
  691. // }
  692. ksharedAppDelegate.supportScreenRotateType = NO;
  693. if(ksharedAppDelegate.getSystemPermissType){
  694. HLog(@"检测到获取系统全进入后台");
  695. return;
  696. }
  697. BOOL haveGuide = [HWDataManager getBoolWithKey:Const_Have_Show_Guide];
  698. if (haveGuide) {
  699. ;
  700. }else {
  701. return;
  702. }
  703. BOOL isPrivacyMode = [HWDataManager getBoolWithKey:Const_Have_Add_Device_Privacy_Mode];
  704. if(ksharedAppDelegate.DeviceThirdIdMod){
  705. isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  706. }
  707. if(!isPrivacyMode){
  708. return;
  709. }
  710. //修复扫描已经有密码的合作 点击跳过因为网络弹框再次覆盖一次密码(需要输入两次密码)
  711. BaseNavigationController*curTopNav = (BaseNavigationController*)[iTools appRootViewController];
  712. if([curTopNav isKindOfClass:[BaseNavigationController class]]){
  713. NSArray *vcArr = [curTopNav viewControllers];
  714. if(vcArr && vcArr.count >0){
  715. UIViewController *lastVC = vcArr.lastObject;
  716. if([lastVC isKindOfClass:[inputPWDViewController class]]){
  717. return;
  718. }
  719. }
  720. }
  721. /*无有效时长直接返回不加载任何加密界面*/
  722. NSString *PwdStr = nil;
  723. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  724. //实时拿到的密码 (每次打开或者更换设备 通过SN重新拿)
  725. if(ksharedAppDelegate.DeviceThirdIdMod.data.password){
  726. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  727. NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  728. if(desPwdStr){
  729. PwdStr = desPwdStr;
  730. }
  731. }
  732. else{
  733. //本地密码本地判断 密码改在服务器保持
  734. if ([[deviceDict allKeys] containsObject:Const_Have_Add_Device_PWD]){
  735. PwdStr = [deviceDict objectForKey:Const_Have_Add_Device_PWD];
  736. }
  737. }
  738. if (!PwdStr || [PwdStr isEqualToString:@""])
  739. {
  740. return;
  741. }
  742. // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_Mask_View_Open];
  743. // if (!haveOpenMask){
  744. // //输入密码界面
  745. // [self closeCalculatorVC];
  746. // _inputVC = [[inputPWDViewController alloc] init];
  747. // [self.window addSubview:_inputVC.view];
  748. // return;
  749. // }
  750. BOOL haveVaildTime = [HWDataManager getBoolWithKey:Const_Have_No_VaildTime];
  751. if (haveVaildTime == YES){/*无有效时间*/
  752. return;
  753. }
  754. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus != AFNetworkReachabilityStatusNotReachable)
  755. {
  756. if(!ksharedAppDelegate.DeviceThirdIdMod){
  757. return;
  758. }
  759. BOOL isPrivacyMode = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  760. if(!isPrivacyMode)
  761. {
  762. ksharedAppDelegate.isFirstInputPwdDone = YES;
  763. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  764. return;
  765. }
  766. }
  767. #ifdef developJSQ
  768. NSInteger maskModel = 1;// [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  769. #else
  770. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  771. #endif
  772. if (maskModel == 0){
  773. //输入密码界面
  774. [self closeCalculatorVC];
  775. _inputVC = [[inputPWDViewController alloc] init];
  776. [self.window addSubview:_inputVC.view];
  777. ksharedAppDelegate.isDidShowPwdType = YES;
  778. }
  779. else if (maskModel == 2){
  780. /*浏览器*/
  781. [self closeCalculatorVC];
  782. _webVC = [[HWWebViewController alloc] init];
  783. _webVC.pwd = PwdStr;
  784. _webVC.webUrl = @"https://baidu.com";
  785. [self.window addSubview:_webVC.view];
  786. ksharedAppDelegate.isDidShowPwdType = YES;
  787. }else{
  788. /*计算器*/
  789. [self closeCalculatorVC];
  790. _calculatorVC = [[CalculatorViewController alloc] init];
  791. _calculatorVC.pwd = PwdStr;
  792. [self.window addSubview:_calculatorVC.view];
  793. ksharedAppDelegate.isDidShowPwdType = YES;
  794. }
  795. [[NSNotificationCenter defaultCenter] postNotificationName:ShowPwdVCNotification object:nil];
  796. }
  797. - (void)closeCalculatorVC{
  798. ksharedAppDelegate.getSystemPermissType = NO;
  799. if (_calculatorVC){
  800. [_calculatorVC.view removeFromSuperview];
  801. }
  802. /*浏览器*/
  803. if (_webVC){
  804. [_webVC.view removeFromSuperview];
  805. }
  806. if(_inputVC){
  807. [_inputVC.view removeFromSuperview];
  808. }
  809. ksharedAppDelegate.isDidShowPwdType = NO;
  810. if(self->_session && self->_connectionOptions){
  811. [self scene:self->_session openURLContexts:self->_connectionOptions.URLContexts];
  812. }
  813. }
  814. - (NSString *)documentPathForAccount:(NSString *)account fileFolder:(NSString *)fileFolder {
  815. NSString *path = DocumentPath;
  816. if (account.length != 0) {
  817. path = [NSString stringWithFormat:@"%@/%@/",DocumentPath,account];
  818. }
  819. if ([fileFolder containsString:@"/"]) {
  820. NSString *path1 = [path stringByAppendingPathComponent:fileFolder];
  821. path1 = [path1 stringByDeletingLastPathComponent];
  822. NSError *error;
  823. if (![[NSFileManager defaultManager] fileExistsAtPath:path1]) {
  824. [[NSFileManager defaultManager] createDirectoryAtPath:path1 withIntermediateDirectories:YES attributes:nil error:&error];
  825. }
  826. }else{
  827. NSError *error;
  828. if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
  829. [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
  830. }
  831. }
  832. return [path stringByAppendingPathComponent:fileFolder];
  833. }
  834. - (void)startUseBtnBePressed{
  835. [self enterMainVCFromScene];
  836. // NSString *launchAppPWDPath = [self documentPathForAccount:@"" fileFolder:@"LaunchPWD"];
  837. // NSString *str = [[NSString alloc] initWithContentsOfFile:launchAppPWDPath encoding:(NSUTF8StringEncoding) error:nil];
  838. // if (!str || [str isEqualToString:@"0"])
  839. // {
  840. // SetUsePWDViewController *loginVC = [[SetUsePWDViewController alloc] init];
  841. // loginVC.delegate = self;
  842. // self.window.rootViewController = loginVC;
  843. //
  844. // return;
  845. // }
  846. //
  847. // NSArray *dataArray = [BaseModel bg_findAll:DB_BrowserWindows_TableName];
  848. //
  849. // if (dataArray.count == 0) { // 浏览器没有窗口
  850. // // 加载首页
  851. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  852. // vc.webUrl = Const_HomeUrl;
  853. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  854. // self.window.rootViewController = nvc;
  855. //
  856. // }else {
  857. // // 浏览器当前窗口索引ID
  858. // NSInteger ID = [HWDataManager getIntegerWithKey:BrowserWindowsCurrentID];
  859. // NSString *where = [NSString stringWithFormat:@"where %@=%ld",bg_sqlKey(@"ID"),(long)ID];
  860. // NSArray* finfAlls = [BaseModel bg_find:DB_BrowserWindows_TableName where:where];
  861. // BaseModel *model = finfAlls.firstObject;
  862. //
  863. // // 加载网页
  864. // HWWebViewController *vc = [[HWWebViewController alloc] init];
  865. // vc.webUrl = model.webUrl;
  866. // UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  867. // self.window.rootViewController = nvc;
  868. // }
  869. }
  870. - (void)loginOk{
  871. [self enterMainVCFromScene];
  872. }
  873. - (void)guideOk:(NSNotification*)not{
  874. NSString *object = not.object;
  875. if(object && [object isEqualToString:@"isLoginAgainType"]){
  876. self.isLoginAgainType = YES;
  877. }
  878. //clear下载和上传的已经获取的数据
  879. // [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  880. // [uploadFileManager shareInstance].databaseArr = [NSMutableArray new];
  881. // [uploadFileManager shareInstance].fileModelDataArr = [NSMutableArray new];
  882. // [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateWait;
  883. [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
  884. [nasUploadFileManager shareInstance].databaseArr = nil;
  885. // [[downloadManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  886. // [downloadManager shareInstance].databaseArr = [NSMutableArray new];
  887. // [downloadManager shareInstance].downLoadFileModelDataArr = [NSMutableArray new];
  888. [[nasDownloadFileManager shareInstance] suspendDownloadFileFun:YES withModel:nil];
  889. [nasDownloadFileManager shareInstance].databaseArr = nil;
  890. //[[backupsFileManager shareInstance] suspendBackupsFileFun];
  891. [[nasBackupsManager shareInstance] suspendBackupsFileFun];
  892. //frp的下载
  893. [[customDownloadManager shareManager] suspendAllDownloadTask];
  894. NSString *uid =ksharedAppDelegate.DeviceThirdIdMod.data.sn;
  895. if(uid){
  896. }
  897. else{
  898. uid = @"";
  899. }
  900. [customDownloadManager shareManager].uid = uid;
  901. //盒子1音频在播放音乐,切换盒子2成功,仍在播放中
  902. [[DFPlayer sharedPlayer] df_deallocPlayer];
  903. [lastFileManager shareManager].uid = uid;
  904. [audioPlayListManager shareManager].uid = uid;
  905. [self enterMainVCFromScene];
  906. }
  907. #pragma mark 上报版本号信息
  908. -(void)reportVersionInfoFun
  909. {
  910. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  911. NSString *vers = [iPhone appVersion];
  912. if(vers){
  913. [paraDict setValue:vers forKey:@"iosClientVersionNumber"];
  914. }
  915. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  916. if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  917. NSString*snStr = deviceDict[Const_Have_Add_Device_SN];
  918. if(snStr){
  919. [paraDict setValue:snStr forKey:@"sn"];
  920. }
  921. else{
  922. return;
  923. }
  924. }
  925. else{
  926. return;;
  927. }
  928. // KWeakSelf
  929. [[netWorkManager shareInstance] CommonPostCallBackCode:reportVersionInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  930. } failure:^(NSError * _Nonnull error) {
  931. }];
  932. }
  933. #pragma mark 获取NAS相关信息
  934. -(void)getNASMsgFun
  935. {
  936. NSMutableDictionary *paraDict = [NSMutableDictionary new];
  937. NSString *SNStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
  938. if(SNStr){
  939. [paraDict setValue:SNStr forKey:@"sn"];
  940. }
  941. else{
  942. return;;
  943. }
  944. KWeakSelf
  945. [[netWorkManager shareInstance] CommonGetWithCallBackCode:getIpFun Parameters:paraDict success:^(id _Nonnull responseObject){
  946. NASMsgModel *model = [[NASMsgModel alloc] initWithDictionary:responseObject error:nil];
  947. if(model){
  948. ksharedAppDelegate.NASMsgMod = model;
  949. }
  950. } failure:^(NSError * _Nonnull error) {
  951. }];
  952. }
  953. #pragma mark 主动上锁
  954. - (void)showLockViewFun:(NSNotification*)not
  955. {
  956. [self showCalculatorVC];
  957. }
  958. #pragma mark 进入设置密码
  959. //- (void)setPwdVCFun:(NSNotification*)not
  960. //{
  961. // _isNeedToShowSecretKey = YES;
  962. //}
  963. #pragma mark 忘记密码
  964. - (void)forgetPwdFun:(NSNotification*)not
  965. {
  966. /*忘记密码*/
  967. forgetPwdViewController *forgetPwdVC = [[forgetPwdViewController alloc] init];
  968. BaseNavigationController *forgetPwdVCNav = [[BaseNavigationController alloc] initWithRootViewController:forgetPwdVC];
  969. self.window.rootViewController = forgetPwdVCNav;
  970. }
  971. #pragma mark 忘记密码返回
  972. - (void)forgetPwdBackFun:(NSNotification*)not
  973. {
  974. // if(_preRootPlayerNav)
  975. // {
  976. // self.window.rootViewController = _preRootPlayerNav;
  977. // }
  978. // else{
  979. [self enterMainVCFromScene];
  980. //}
  981. [self showCalculatorVC];
  982. }
  983. #pragma mark 忘记密码设置密码完成
  984. - (void)forgetPwdDidSetPwdFun:(NSNotification*)not
  985. {
  986. // if(_preRootPlayerNav)
  987. // {
  988. // NSArray *vcArr = _preRootPlayerNav.viewControllers;
  989. // if(vcArr.count > 2){
  990. // [_preRootPlayerNav popToViewController:vcArr[1] animated:NO];
  991. // }
  992. // self.window.rootViewController = _preRootPlayerNav;
  993. // }
  994. // else{
  995. [self enterMainVCFromScene];
  996. //}
  997. [self closeCalculatorVC];
  998. ksharedAppDelegate.isFirstInputPwdDone = YES;
  999. }
  1000. #pragma mark 扫码切换设备 scanChangeDeviceNotification
  1001. - (void)scanChangeDeviceFun:(NSNotification*)not
  1002. {
  1003. //TipsQRCodeForChangeDeviceViewController *nextVC = [[TipsQRCodeForChangeDeviceViewController alloc] init];
  1004. QRCodeScanForChangeDeviceViewController *nextVC = [[QRCodeScanForChangeDeviceViewController alloc] init];
  1005. nextVC.isRootVCType = YES;
  1006. BaseNavigationController *nextNav = [[BaseNavigationController alloc] initWithRootViewController:nextVC];
  1007. self.window.rootViewController = nextNav;
  1008. }
  1009. #pragma mark 扫码切换设备点击返回
  1010. - (void)scanChangeDeviceBackFun:(NSNotification*)not
  1011. {
  1012. // if(_preRootPlayerNav)
  1013. // {
  1014. // self.window.rootViewController = _preRootPlayerNav;
  1015. // }
  1016. // else{
  1017. [self enterMainVCFromScene];
  1018. //}
  1019. [self showCalculatorVC];
  1020. }
  1021. #pragma mark 网络异常弹框
  1022. -(void)showNetErrorAlertFun
  1023. {
  1024. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  1025. if(maskModel !=0 && ksharedAppDelegate.isDidShowPwdType){
  1026. return;
  1027. }
  1028. NSString *linkErrTip = NSLocalizedString(@"player_link_fail_tip_type9",nil);
  1029. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  1030. //linkErrTip = NSLocalizedString(@"player_link_fail_phone_Tips",nil);
  1031. _isNeedToStopWork = YES;
  1032. [self showNetErrorAlertType2Fun];
  1033. return;
  1034. }
  1035. linkErrTip = [[NSString alloc] initWithFormat:@"[9]%@",linkErrTip];
  1036. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:nil
  1037. msg:linkErrTip
  1038. imageStr:nil
  1039. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  1040. okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
  1041. didClickOk:^{
  1042. //[self enterMainVCFromScene];
  1043. } didClickCancel:^{
  1044. exit(0);
  1045. }];
  1046. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1047. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  1048. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1049. }];
  1050. }
  1051. #pragma mark 网络异常弹框
  1052. -(void)showNetErrorAlertType2Fun
  1053. {
  1054. if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable){
  1055. NSString * linkErrTip = NSLocalizedString(@"netWork_error_tip_content",nil);
  1056. ComontAlretViewController *linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"netWork_error_tip_title",nil)
  1057. msg:linkErrTip
  1058. imageStr:nil
  1059. cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
  1060. okTitle:nil isOkBtnHighlight:NO
  1061. didClickOk:^{
  1062. //[self enterMainVCFromScene];
  1063. } didClickCancel:^{
  1064. exit(0);
  1065. }];
  1066. linkFailAlretVC.modalPresentationStyle = UIModalPresentationCustom;
  1067. self.window.rootViewController = [UIViewController new];
  1068. [self.window.rootViewController presentViewController:linkFailAlretVC animated:YES completion:^{
  1069. linkFailAlretVC.view.superview.backgroundColor = [UIColor clearColor];
  1070. }];
  1071. }
  1072. }
  1073. - (void)gotoScanAginByThridMsgErrorFun:(NSInteger)errorCode
  1074. {
  1075. /*扫码界面*/
  1076. TipsQRCodeViewController *qrCodeVC = [[TipsQRCodeViewController alloc] init];
  1077. qrCodeVC.isNeedToShowAleatType = YES;
  1078. qrCodeVC.getSNMsgcode = errorCode;
  1079. BaseNavigationController *qrCodeVCNav = [[BaseNavigationController alloc] initWithRootViewController:qrCodeVC];
  1080. self.window.rootViewController = qrCodeVCNav;
  1081. }
  1082. #pragma mark 分享页面唤醒APP
  1083. - (void)shareAwakenAppBy:(NSString*)shareStr
  1084. {
  1085. //[[iToast makeText:shareStr] show];
  1086. NSArray * paraArr = [shareStr componentsSeparatedByString:@"&"];
  1087. if(!paraArr || paraArr.count==0){
  1088. return;
  1089. }
  1090. //type=save和download
  1091. NSString *type = nil;
  1092. NSString *fileIds = nil;
  1093. NSString *extractionCode = nil;
  1094. NSString *token = nil;
  1095. for (NSString*objectStr in paraArr) {
  1096. if([objectStr rangeOfString:@"type"].location != NSNotFound){
  1097. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1098. if(objectArr.count == 2){
  1099. type = objectArr.lastObject;
  1100. continue;
  1101. }
  1102. }
  1103. else if([objectStr rangeOfString:@"fileIds"].location != NSNotFound){
  1104. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1105. if(objectArr.count == 2){
  1106. fileIds = objectArr.lastObject;
  1107. continue;
  1108. }
  1109. }
  1110. else if([objectStr rangeOfString:@"extractionCode"].location != NSNotFound){
  1111. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1112. if(objectArr.count == 2){
  1113. extractionCode = objectArr.lastObject;
  1114. continue;
  1115. }
  1116. }
  1117. else if([objectStr rangeOfString:@"token"].location != NSNotFound){
  1118. NSArray * objectArr = [objectStr componentsSeparatedByString:@"="];
  1119. if(objectArr.count == 2){
  1120. token = objectArr.lastObject;
  1121. continue;
  1122. }
  1123. }
  1124. }
  1125. if(!type || type.length ==0){
  1126. HLog(@"分享 type 获取错误");
  1127. return;
  1128. }
  1129. if(!fileIds || fileIds.length ==0){
  1130. HLog(@"分享 fileIds 获取错误");
  1131. return;
  1132. }
  1133. if(!token || token.length ==0){
  1134. HLog(@"分享 token 获取错误");
  1135. return;
  1136. }
  1137. [self getShareOneFileListFunByToken:token withFileIds:fileIds withExtractionCode:extractionCode withType:type];
  1138. }
  1139. #pragma mark 分享信息重新获取
  1140. - (void)getShareOneFileListFunByToken:(NSString*)token withFileIds:(NSString*)fileIds withExtractionCode:(NSString*)extractionCode withType:(NSString*)type
  1141. {
  1142. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1143. fileIds = [fileIds stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  1144. NSData *jsonData = [fileIds dataUsingEncoding:NSUTF8StringEncoding];;
  1145. NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
  1146. HLog(@"jsonArray:%@",jsonArray)
  1147. if(!jsonArray){
  1148. return;
  1149. }
  1150. [paraDict setValue:token forKey:@"token"];
  1151. [paraDict setValue:jsonArray forKey:@"fileIdList"];
  1152. [paraDict setValue:extractionCode forKey:@"extractionCode"];
  1153. KWeakSelf
  1154. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
  1155. queryOneShareModel*model = [[queryOneShareModel alloc] initWithDictionary:responseObject error:nil];
  1156. if(model && model.status == 0){
  1157. weakSelf.getShareStr = nil;
  1158. [weakSelf gotoVCByModel:model withType:type];
  1159. }
  1160. else{
  1161. }
  1162. } failure:^(NSError * _Nonnull error) {
  1163. }];
  1164. }
  1165. #pragma mark 跳转
  1166. - (void)gotoVCByModel:(queryOneShareModel*)model withType:(NSString*)type
  1167. {
  1168. if([type isEqualToString:@"save"]){
  1169. [self saveFileToBoxFunBy:model];
  1170. //数据埋点
  1171. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_save"];
  1172. }
  1173. else if([type isEqualToString:@"download"]){
  1174. [self downloadFileToAppFunBy:model];
  1175. //数据埋点
  1176. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Share_download"];
  1177. }
  1178. }
  1179. #pragma mark 保存文件到盒子
  1180. - (void)saveFileToBoxFunBy:(queryOneShareModel*)sharemodel
  1181. {
  1182. NSMutableDictionary*paraDict = [NSMutableDictionary new];
  1183. NSMutableArray *pathArr = [NSMutableArray new];
  1184. for (ShareFileDataModel*dataModel in sharemodel.data.fileListVOS){
  1185. [pathArr addObject:dataModel.fileUrl];
  1186. }
  1187. if (pathArr) {
  1188. NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
  1189. if(jsonStr){
  1190. [paraDict setValue:jsonStr forKey:@"urls"];
  1191. }
  1192. }
  1193. NSString * boxSaveDefaultPath = [HWDataManager getStringWithKey:stringKeyAddSn(Const_box_save_default_path)];
  1194. if(!boxSaveDefaultPath || boxSaveDefaultPath.length == 0){
  1195. boxSaveDefaultPath = Const_default_save_path;
  1196. [HWDataManager setStringWithKey:stringKeyAddSn(Const_box_save_default_path) value:boxSaveDefaultPath];
  1197. }
  1198. [paraDict setValue:boxSaveDefaultPath forKey:@"savePath"];
  1199. KWeakSelf
  1200. [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downFiles" Parameters:paraDict success:^(id _Nonnull responseObject) {
  1201. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1202. if(model && model.status == 0){
  1203. [weakSelf gotoUploadFileRecordVCFunByType:2 withModel:sharemodel];
  1204. }
  1205. } failure:^(NSError * _Nonnull error) {
  1206. }];
  1207. }
  1208. #pragma mark 下载文件到手机
  1209. - (void)downloadFileToAppFunBy:(queryOneShareModel*)sharemodel
  1210. {
  1211. [self gotoUploadFileRecordVCFunByType:1 withModel:sharemodel];
  1212. }
  1213. #pragma mark 跳转传输列表
  1214. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type withModel:(queryOneShareModel*)sharemodel
  1215. {
  1216. KWeakSelf
  1217. if(type == 2){
  1218. [[boxSaveFileManager shareInstance] addBoxSaveRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1219. if(isSuccess){
  1220. mainBlock(^{
  1221. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1222. });
  1223. }
  1224. }];
  1225. }
  1226. else if (type == 1){
  1227. if(![iTools checkFreeDiskSpaceInBytesIsOK:500*1024*1024]){
  1228. mainBlock(^{
  1229. [[iToast makeText:NSLocalizedString(@"phone_space_Insufficient",nil)] show];
  1230. });
  1231. return;
  1232. }
  1233. [[boxDownloadFileManager shareInstance] addBoxDownloadRecordFunBy:sharemodel.data.fileListVOS complete:^(BOOL isSuccess) {
  1234. if(isSuccess){
  1235. mainBlock(^{
  1236. [weakSelf gotoUploadFileRecordVCFunByType:type];
  1237. });
  1238. }
  1239. }];
  1240. }
  1241. }
  1242. - (void)gotoUploadFileRecordVCFunByType:(NSInteger)type
  1243. {
  1244. uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
  1245. vc.isReceiveType = type;
  1246. BaseNavigationController*mainNav = ksharedAppDelegate.mainTabBar.selectedViewController;
  1247. if([mainNav isKindOfClass:[BaseNavigationController class]]){
  1248. [mainNav pushViewController:vc animated:YES];
  1249. [[UIApplication sharedApplication] setStatusBarHidden:NO];
  1250. }
  1251. }
  1252. #pragma mark UITabBarControllerDelegate
  1253. - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
  1254. {
  1255. NSInteger index = tabBarController.selectedIndex;
  1256. int eventType = 1;
  1257. NSString* eventValue = @"Nas";
  1258. if(index == 0){
  1259. eventValue = @"Nas";
  1260. }
  1261. else if(index == 1){
  1262. eventValue = @"Cloud";
  1263. }
  1264. else if(index == 2){
  1265. eventValue = @"Home";
  1266. }
  1267. //数据埋点
  1268. [[netWorkManager shareInstance] DataEmbeddingPointBy:eventType withEventValue:eventValue];
  1269. }
  1270. - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
  1271. {
  1272. if(ksharedAppDelegate.isCloudPhoneModeNotPrivacyModeOpenType
  1273. || ksharedAppDelegate.isCloudPhoneModeAndPrivacyModeOpenType
  1274. || ksharedAppDelegate.needToPushWebRtcVCType){
  1275. return NO;
  1276. }
  1277. return YES;
  1278. }
  1279. #pragma mark 弹框逻辑放到这里
  1280. //优先级:1.强制盒子更新弹窗
  1281. // 2.APP版本更新弹窗 > 新手引导弹窗 > 通知公告弹窗
  1282. - (void)beginShowAlertFun
  1283. {
  1284. //
  1285. if (!ksharedAppDelegate.mainTabBar) {
  1286. return;
  1287. }
  1288. //1.隐私模式密码界面 3秒检测一次是否输入完成密码了
  1289. if(!ksharedAppDelegate.isFirstInputPwdDone){
  1290. KWeakSelf
  1291. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1292. [weakSelf beginShowAlertFun];
  1293. });
  1294. return;
  1295. }
  1296. // 强制盒子更新弹窗
  1297. [self checkUpgradeInfoFun];
  1298. }
  1299. #pragma mark 弹框流程 1 检测盒子镜像更新弹窗->1.4.4改为从服务器请求
  1300. - (void)checkUpgradeInfoFun
  1301. {
  1302. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1303. [paraDict setValue:@"ota" forKey:@"type"];
  1304. KWeakSelf
  1305. [[netWorkManager shareInstance] CommonPostCallBackCode:queryUpgradeInfo Parameters:paraDict success:^(id _Nonnull responseObject) {
  1306. UpgradeInfoModel *model = [[UpgradeInfoModel alloc] initWithDictionary:responseObject error:nil];
  1307. if (model && model.status == 0) {
  1308. weakSelf.otaUpgradeInfoModel = model;
  1309. [weakSelf handelUpgradeInfoFun];
  1310. }
  1311. else
  1312. {
  1313. //2. APP版本更新弹窗
  1314. [weakSelf checkVersionFun];
  1315. }
  1316. } failure:^(NSError * _Nonnull error) {
  1317. KWeakSelf
  1318. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1319. [weakSelf checkUpgradeInfoFun];
  1320. });
  1321. }];
  1322. }
  1323. #pragma mark 弹框流程 1 强制盒子更新弹窗
  1324. - (void)handelUpgradeInfoFun
  1325. {
  1326. //self.otaUpgradeInfoModel.data.status = 1;
  1327. if(self.otaUpgradeInfoModel.data.status < 1){ //-1=没有更新 0=下载中
  1328. //2. APP版本更新弹窗
  1329. [self checkVersionFun];
  1330. }
  1331. else{
  1332. KWeakSelf
  1333. if(self.otaUpgradeInfoModel.data.status < 6){
  1334. [self showImageViewRenewTipViewFun];
  1335. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1336. [weakSelf checkUpgradeInfoFun];
  1337. });
  1338. }
  1339. else if(self.otaUpgradeInfoModel.data.status == 6){//升级完成
  1340. if(RenewTipView){
  1341. [self showImageViewRenewTipViewFun];
  1342. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1343. [weakSelf OTAUpdateDoneFun];
  1344. });
  1345. }
  1346. else{
  1347. [self OTAUpdateDoneFun];
  1348. }
  1349. }
  1350. else if(self.otaUpgradeInfoModel.data.status == 201){//升级失败
  1351. //显示升级失败
  1352. [self OTAUpdateFailFun];
  1353. }
  1354. else{
  1355. //2. APP版本更新弹窗
  1356. [self checkVersionFun];
  1357. }
  1358. }
  1359. }
  1360. #pragma mark 弹框流程 1 强制盒子更新弹窗
  1361. - (void)showImageViewRenewTipViewFun
  1362. {
  1363. //密码框界面 拦着 不给弹出
  1364. if(ksharedAppDelegate.isDidShowPwdType){
  1365. //didGetSysInfoType = NO;
  1366. KWeakSelf
  1367. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1368. [weakSelf showImageViewRenewTipViewFun];
  1369. });
  1370. return;
  1371. }
  1372. if(RenewTipView){
  1373. RenewTipView.status = _otaUpgradeInfoModel.data.status;
  1374. return;
  1375. }
  1376. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  1377. CGFloat second = 0.1;
  1378. if(haveOpenMask){
  1379. second = 1.5;
  1380. [[NSNotificationCenter defaultCenter] postNotificationName:needToPoPCloudPhoneVCNotification object:nil];
  1381. }
  1382. KWeakSelf
  1383. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1384. self->RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1385. [ksharedAppDelegate.window addSubview:self->RenewTipView];
  1386. self->RenewTipView.status = self->_otaUpgradeInfoModel.data.status;
  1387. //[self.view bringSubviewToFront:RenewTipView];
  1388. self->RenewTipView.didClickUpdateNowFun = ^{
  1389. [weakSelf otaUpdateNowFun];
  1390. };
  1391. self->RenewTipView.didClickCloseFun = ^{
  1392. [weakSelf didClickRenewTipViewCloseFun];
  1393. };
  1394. });
  1395. }
  1396. - (void)didClickRenewTipViewCloseFun{
  1397. RenewTipView = nil;
  1398. }
  1399. #pragma mark 弹框流程 1 盒子更新弹窗 点击立即更新
  1400. - (void)otaUpdateNowFun
  1401. {
  1402. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1403. [paraDict setValue:@"ota" forKey:@"type"];
  1404. [paraDict setValue:@2 forKey:@"status"];
  1405. KWeakSelf
  1406. [[netWorkManager shareInstance] CommonPostCallBackCode:upgradeDetailAdd Parameters:paraDict success:^(id _Nonnull responseObject) {
  1407. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1408. if (model && model.status == 0) {
  1409. [weakSelf checkUpgradeInfoFun];
  1410. }
  1411. else
  1412. {
  1413. [weakSelf checkVersionFun];
  1414. }
  1415. } failure:^(NSError * _Nonnull error) {
  1416. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1417. [weakSelf otaUpdateNowFun];
  1418. });
  1419. }];
  1420. //1.点击更新 标志 30分别 不谈 心跳弹框
  1421. long seconds = [iTools getNowTimeStamp];
  1422. NSNumber *secondsNum = [NSNumber numberWithLong:seconds];
  1423. if(secondsNum){
  1424. [HWDataManager setNumberWithKey:stringKeyAddSn(@"disenable_type1_BoxHeartbeat") value:secondsNum];
  1425. }
  1426. }
  1427. #pragma mark 弹框流程 1 OTA升级完成
  1428. - (void)OTAUpdateDoneFun
  1429. {
  1430. //密码框界面 拦着 不给弹出
  1431. if(ksharedAppDelegate.isDidShowPwdType){
  1432. KWeakSelf
  1433. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1434. [weakSelf OTAUpdateDoneFun];
  1435. });
  1436. return;
  1437. }
  1438. if(RenewTipView){
  1439. [RenewTipView removeFromSuperview];
  1440. RenewTipView = nil;
  1441. }
  1442. if (imageVersionUpdateDoneV) {
  1443. [imageVersionUpdateDoneV removeFromSuperview];
  1444. imageVersionUpdateDoneV = nil;
  1445. }
  1446. //显示OTA完成页面
  1447. imageVersionUpdateDoneV = [[imageVersionUpdateDoneView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1448. [ksharedAppDelegate.window addSubview:imageVersionUpdateDoneV];
  1449. //[self.view bringSubviewToFront:curView];
  1450. KWeakSelf
  1451. imageVersionUpdateDoneV.didClickUpdateDoneFun = ^{
  1452. [weakSelf closeOTAUpdateDoneFun];
  1453. };
  1454. }
  1455. #pragma mark 弹框流程 1 OTA升级失败
  1456. - (void)OTAUpdateFailFun
  1457. {
  1458. //密码框界面 拦着 不给弹出
  1459. if(ksharedAppDelegate.isDidShowPwdType){
  1460. KWeakSelf
  1461. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1462. [weakSelf OTAUpdateFailFun];
  1463. });
  1464. return;
  1465. }
  1466. if(RenewTipView){
  1467. [RenewTipView removeFromSuperview];
  1468. RenewTipView = nil;
  1469. }
  1470. if (imageVersionUpdateFailV) {
  1471. [imageVersionUpdateFailV removeFromSuperview];
  1472. imageVersionUpdateFailV = nil;
  1473. }
  1474. //显示OTA完成页面
  1475. imageVersionUpdateFailV = [[imageVersionUpdateFailView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
  1476. [ksharedAppDelegate.window addSubview:imageVersionUpdateFailV];
  1477. //[self.view bringSubviewToFront:curView];
  1478. KWeakSelf
  1479. imageVersionUpdateFailV.didClickUpdateDoneFun = ^{
  1480. [weakSelf closeOTAUpdateDoneFun];
  1481. };
  1482. }
  1483. #pragma mark 弹框流程 1 盒子更新弹窗 关闭弹窗
  1484. - (void)closeOTAUpdateDoneFun
  1485. {
  1486. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1487. [paraDict setValue:@"ota" forKey:@"type"];
  1488. [paraDict setValue:@1 forKey:@"popButton"];
  1489. KWeakSelf
  1490. [[netWorkManager shareInstance] CommonPostCallBackCode:updateOTAPopButton Parameters:paraDict success:^(id _Nonnull responseObject) {
  1491. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1492. if (model && model.status == 0) {
  1493. }
  1494. else
  1495. {
  1496. }
  1497. [weakSelf checkVersionFun];
  1498. } failure:^(NSError * _Nonnull error) {
  1499. [weakSelf checkVersionFun];
  1500. }];
  1501. }
  1502. #pragma mark 弹框流程 2 APP版本更新弹窗
  1503. - (void)checkVersionFun
  1504. {
  1505. //[self getVersion];
  1506. [self getLastNoticeFun];
  1507. }
  1508. #pragma mark- 网络请求
  1509. - (void)getVersion {
  1510. //密码框界面 拦着 不给弹出
  1511. if(!ksharedAppDelegate.isFirstInputPwdDone){
  1512. return;
  1513. }
  1514. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1515. [paraDict setValue:@"ios" forKey:@"type"];
  1516. [paraDict setValue:@"skyworth" forKey:@"source"];
  1517. [paraDict setValue:@"iPhone" forKey:@"iosType"];
  1518. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  1519. //HLog(@"%@", responseObject);
  1520. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  1521. if (model && model.status == 0) {
  1522. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  1523. [self checkVersion:model];
  1524. }
  1525. else
  1526. {
  1527. [self checkVersion:nil];
  1528. }
  1529. } failure:^(NSError * _Nonnull error) {
  1530. HLog(@"%@", error);
  1531. [self checkVersion:nil];
  1532. }];
  1533. }
  1534. - (void)checkVersion:(HWVersionModel*)versionModel {
  1535. if(!versionModel){//版本信息错误 检测新手弹框流程
  1536. //[self showNewerGuideFun];
  1537. [self getLastNoticeFun];
  1538. return;
  1539. }
  1540. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  1541. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  1542. NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  1543. newVersion = [newVersion stringByReplacingOccurrencesOfString:@"V" withString:@""]; //去掉v
  1544. //HLog(@"%@---%@", newVersion, currentVersion);
  1545. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  1546. //[self showNewerGuideFun];
  1547. [self getLastNoticeFun];
  1548. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  1549. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  1550. //[self showNewerGuideFun];
  1551. [self getLastNoticeFun];
  1552. }else { // 本地版本号 < 服务器版本号 (有新版本)
  1553. [self showNewVersion:versionModel];
  1554. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  1555. };
  1556. }
  1557. - (void)showNewVersion:(HWVersionModel*)versionModel {
  1558. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  1559. if (haveNewVersionView.isShow) {
  1560. return;
  1561. }
  1562. //此版本点击过稍后再试
  1563. NSString *preVersionstr = [HWDataManager getStringWithKey:Const_did_show_version_and_click_wait];
  1564. if(preVersionstr && [versionModel.versionNumber isEqualToString:preVersionstr]){
  1565. //[self showNewerGuideFun];
  1566. [self getLastNoticeFun];
  1567. return;
  1568. }
  1569. haveNewVersionView.versionModel = versionModel;
  1570. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  1571. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  1572. [ksharedAppDelegate.window addSubview:haveNewVersionView];
  1573. haveNewVersionView.isShow = YES;
  1574. if(!versionModel.necessary){
  1575. haveNewVersionView.deleteBtn.hidden = NO;
  1576. }
  1577. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1578. make.top.mas_equalTo(0);
  1579. make.left.mas_equalTo(0);
  1580. make.right.mas_equalTo(0);
  1581. make.bottom.mas_equalTo(0);
  1582. }];
  1583. haveNewVersionView.alpha = 0.0;
  1584. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1585. haveNewVersionView.alpha = 1.0;
  1586. KyoLog(@"in animate start");
  1587. } completion:^(BOOL finished) {
  1588. KyoLog(@"in animate completion");
  1589. }];
  1590. KWeakSelf
  1591. haveNewVersionView.closeViewFun = ^{
  1592. //[weakSelf showNewerGuideFun];
  1593. [weakSelf getLastNoticeFun];
  1594. };
  1595. }
  1596. //#pragma mark 弹框流程 3 新手引导弹窗
  1597. //- (void)showNewerGuideFun
  1598. //{
  1599. // BOOL didShow = [HWDataManager getBoolWithKey:@"Const_did_show_newer_Guide"];
  1600. //
  1601. // if(didShow){
  1602. // [self getLastNoticeFun];
  1603. // return;
  1604. // }
  1605. //
  1606. // //密码框界面 拦着 不给弹出
  1607. // if(ksharedAppDelegate.isDidShowPwdType){
  1608. // KWeakSelf
  1609. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1610. // [weakSelf showNewerGuideFun];
  1611. // });
  1612. // return;
  1613. // }
  1614. //
  1615. // newerGuideView *guideView = [[newerGuideView alloc] init];
  1616. // [ksharedAppDelegate.window addSubview:guideView];
  1617. //
  1618. // [guideView mas_makeConstraints:^(MASConstraintMaker *make) {
  1619. // make.top.mas_equalTo(0);
  1620. // make.left.mas_equalTo(0);
  1621. // make.right.mas_equalTo(0);
  1622. // make.bottom.mas_equalTo(0);
  1623. // }];
  1624. //
  1625. //
  1626. // KWeakSelf
  1627. // guideView.didClickButtonFun = ^(NSInteger tag) {
  1628. // [weakSelf didiClickNewerButtonFunBy:tag];
  1629. // };
  1630. //
  1631. //}
  1632. //
  1633. //#pragma mark 新手引导点击事件
  1634. //- (void)didiClickNewerButtonFunBy:(NSInteger)tag
  1635. //{
  1636. // [HWDataManager setBoolWithKey:@"Const_did_show_newer_Guide" value:YES];
  1637. //
  1638. // if(tag ==1){
  1639. // [self getLastNoticeFun];
  1640. // }
  1641. // else if(tag ==2 || tag == 10){
  1642. // CustomerWebViewController *vc = [[CustomerWebViewController alloc] init];
  1643. // vc.titleStr = NSLocalizedString(@"mine_newuser_title",nil);
  1644. //
  1645. // NSString *url = [[NSString alloc] initWithFormat:@"%@/warrantyService/index.html#/novice?isNovice=true",CloudService];
  1646. // if(tag == 10){
  1647. // url = [url stringByReplacingOccurrencesOfString:@"?isNovice=true" withString:@""];
  1648. // }
  1649. //
  1650. // vc.webUrl = url;
  1651. // //[self pushViewController:vc animated:YES];
  1652. //
  1653. // NSArray*curVCArr = ksharedAppDelegate.mainTabBar.viewControllers;
  1654. // NSInteger selectedIndex = ksharedAppDelegate.mainTabBar.selectedIndex;
  1655. //
  1656. // if(selectedIndex < curVCArr.count){
  1657. // UIViewController * curVC = curVCArr[selectedIndex];
  1658. // [curVC.navigationController pushViewController:curVC animated:YES];
  1659. //
  1660. // KWeakSelf
  1661. // vc.didClickBackFun = ^{
  1662. // [weakSelf getLastNoticeFun];
  1663. // };
  1664. // }
  1665. //
  1666. // }
  1667. //}
  1668. #pragma mark 弹框流程 4 通知公告弹窗
  1669. - (void)getLastNoticeFun
  1670. {
  1671. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  1672. [paraDict setValue:@"Private-X" forKey:@"productType"];
  1673. [paraDict setValue:@"ios" forKey:@"type"];
  1674. [[netWorkManager shareInstance] CommonPostCallBackCode:queryOneNotice Parameters:paraDict success:^(id _Nonnull responseObject) {
  1675. noticeModel *model = [[noticeModel alloc] initWithDictionary:responseObject error:nil];
  1676. //test code
  1677. // model.status = 0;
  1678. // model.data = [noticeDataModel new];
  1679. // model.data.curNoticeId = @"1111";
  1680. // model.data.title = @"版本升级通知公告";
  1681. // model.data.content = @"1.偶现挤下线问题";
  1682. // model.data.content = @"1.偶现挤下线问题\n2.本地网络弹框\n3.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n4.上传偶现UI刷新异常(数据库是正常的)\n5.偶现上传文件损坏\n6.链接不稳定问题(websock偶尔会不断重连\n7.进入设置页面读取数据偶现闪退!!!!\n8.本地网络弹框\n9.访问相册权限之类的系统弹框会触发进入后台流程---显示输入密码框\n10.上传偶现UI刷新异常(数据库是正常的)\n11.偶现上传文件损坏\n12.链接不稳定问题(websock偶尔会不断重连)\n13.进入设置页面读取数据偶现闪退!!!!\n14.本地网络弹框\n15.访问相册权限之类的系统弹框会触发进入后台流程\n16.上传偶现UI刷新异常(数据库是正常的)";//\n17.偶现上传文件损坏\n18.链接不稳定问题(websock偶尔会不断重连\n19.进入设置页面读取数据偶现闪退!!!!\n20.本地网络弹框\n21.访问相册权限之类的系统弹框会触发进入后台流程\n22.上传偶现UI刷新异常(数据库是正常的)\n23.偶现上传文件损坏\n24.链接不稳定问题(websock偶尔会不断重连)\n25.进入设置页面读取数据偶现闪退!!!!\n26.本地网络弹框\n27.访问相册权限之类的系统弹框会触发进入后台流程\n28.上传偶现UI刷新异常(数据库是正常的)\n29.偶现上传文件损坏\n30.链接不稳定问题(websock偶尔会不断重连)\n31.进入设置页面读取数据偶现闪退!!!!";
  1683. if (model && model.data && model.status == 0) {
  1684. [self showHaveNoticeViewBy:model];
  1685. }
  1686. else
  1687. {
  1688. }
  1689. } failure:^(NSError * _Nonnull error) {
  1690. HLog(@"%@", error);
  1691. }];
  1692. }
  1693. - (void)showHaveNoticeViewBy:(noticeModel*)model
  1694. {
  1695. //密码框界面 拦着 不给弹出
  1696. if(ksharedAppDelegate.isDidShowPwdType){
  1697. KWeakSelf
  1698. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1699. [weakSelf showHaveNoticeViewBy:model];
  1700. });
  1701. return;
  1702. }
  1703. HaveNoticeView * noticeView = [HaveNoticeView shardInstance];
  1704. NSString * preShowID = [HWDataManager getStringWithKey:Const_did_show_Notice_ID];
  1705. if(noticeView.isShow
  1706. || !model
  1707. || [preShowID isEqualToString:model.data.curNoticeId]){
  1708. return;
  1709. }
  1710. noticeView.curNoticeModel = model;
  1711. //异常处理
  1712. if(![iTools getKeyWindow]){
  1713. return;
  1714. }
  1715. [[iTools getKeyWindow] addSubview:noticeView];
  1716. [noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
  1717. make.top.mas_equalTo(0);
  1718. make.left.mas_equalTo(0);
  1719. make.right.mas_equalTo(0);
  1720. make.bottom.mas_equalTo(0);
  1721. }];
  1722. noticeView.alpha = 0.0;
  1723. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  1724. noticeView.alpha = 1.0;
  1725. } completion:^(BOOL finished) {
  1726. }];
  1727. }
  1728. @end