OfflineSettingViewController.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. //
  2. // OfflineSettingViewController.m
  3. // iSales-NPD
  4. //
  5. // Created by Ray on 5/11/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "OfflineSettingViewController.h"
  9. #import "iSalesNetwork.h"
  10. #import "MainViewController.h"
  11. #import "LoginViewController.h"
  12. #import "OLDataProvider.h"
  13. #import "OfflineUnlockViewController.h"
  14. //#import "SyncControlPanelViewController.h"
  15. @interface OfflineSettingViewController ()
  16. @end
  17. @implementation OfflineSettingViewController
  18. - (IBAction)onUnlockClicked:(id)sender {
  19. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Unlock offline" message:@"Unlock offline to sync with another account. Current user data will lost!" preferredStyle:UIAlertControllerStyleAlert];
  20. //block代码块取代了delegate
  21. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Unlock" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  22. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  23. sqlite3* db = [iSalesDB get_db];
  24. int offline_user_iscurrent=[iSalesDB get_recordcount:db table:@"offline_login" where:[NSString stringWithFormat:@"username='%@'",appDelegate.user ]];
  25. [iSalesDB close_db:db];
  26. if(offline_user_iscurrent>0)
  27. {
  28. self.bunlock=true;
  29. }
  30. else
  31. {
  32. OfflineUnlockViewController * unlockvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"OfflineUnlockViewController"];
  33. unlockvc.returnValue = ^(bool blogin){
  34. self.bunlock=true;
  35. };
  36. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:unlockvc] ;
  37. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  38. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  39. [self presentViewController:navi animated:YES completion:^{
  40. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  41. DebugLog(@"LoginViewController present.........");
  42. // self.btop = false;
  43. // <#code#>
  44. }];
  45. }
  46. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure remove all models from cart?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  47. // //block代码块取代了delegate
  48. //
  49. //
  50. //
  51. // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  52. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Models From Cart"];
  53. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  54. //
  55. // NSDictionary* cart_json = [iSalesNetwork cart_remove:ids];
  56. //
  57. // dispatch_async(dispatch_get_main_queue(), ^{
  58. //
  59. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  60. //
  61. // if([[cart_json valueForKey:@"result"] intValue]==2)
  62. // {
  63. //
  64. // [self end_edit];
  65. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  66. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
  67. // [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
  68. // }
  69. // else
  70. // {
  71. // [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
  72. // }
  73. //
  74. //
  75. //
  76. // });
  77. // });
  78. //
  79. //
  80. // }];
  81. //
  82. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  83. // DebugLog(@"No");
  84. // }];
  85. // [alertControl addAction:actionOne];
  86. //
  87. // [alertControl addAction:alertthree];
  88. //
  89. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  90. //
  91. //
  92. // [self presentViewController:alertControl animated:YES completion:nil];
  93. //
  94. // DebugLog(@"%@",self.edit_select_arr);
  95. //
  96. //
  97. }];
  98. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  99. DebugLog(@"No");
  100. }];
  101. [alertControl addAction:actionOne];
  102. [alertControl addAction:alertthree];
  103. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  104. [self presentViewController:alertControl animated:YES completion:nil];
  105. }
  106. - (void)viewDidLoad {
  107. [super viewDidLoad];
  108. self.bunlock=false;
  109. // Do any additional setup after loading the view.
  110. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  111. bool offline = [defaults boolForKey:@"EnableOfflineMode"] ;
  112. NSString* ver = [defaults stringForKey:@"OfflineVer"] ;
  113. NSString* lastsync = [defaults stringForKey:@"LastSync"] ;
  114. if(lastsync!=nil)
  115. self.label_sync.text = lastsync;
  116. if(ver==nil)
  117. self.label_ver.text=@"No offline data";
  118. else
  119. self.label_ver.text=ver;
  120. self.switch_offline.on = offline;
  121. self.edgesForExtendedLayout = UIRectEdgeNone ;
  122. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  123. style:UIBarButtonItemStylePlain
  124. target:self
  125. action:@selector( onCloseClick:)];
  126. self.navigationItem.rightBarButtonItem = closeButton;
  127. }
  128. - (IBAction)OnCheckUpdate:(id)sender {
  129. UIApplication * app = [UIApplication sharedApplication];
  130. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  131. if(appDelegate.bLogin==false)
  132. {
  133. LoginViewController * loginvc =[ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  134. loginvc.returnValue = ^(bool blogin){
  135. if(blogin)
  136. {
  137. if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  138. {
  139. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  140. NSString* ver = [defaults stringForKey:@"OfflineVer"] ;
  141. if(sender==nil)
  142. {
  143. [appDelegate check_offline:ver useInternalAddress:self.switch_internal_address.isOn parentvc:self];
  144. // SyncControlPanelViewController * syncVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"SyncControlPanelViewController"];
  145. // syncVC.action_string=@"Download";
  146. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:syncVC] ;
  147. //
  148. //
  149. //
  150. //
  151. //
  152. // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  153. //
  154. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  155. // [self presentViewController:navi animated:YES completion:^{
  156. //
  157. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  158. //
  159. // DebugLog(@"about present.........");
  160. //
  161. // // self.btop = false;
  162. // // <#code#>
  163. // }];
  164. }
  165. else
  166. {
  167. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Check offline update?" message:@"Please connect to WIFI network and plug charging cable, KEEP SCREEN ON AND KEEP APP RUNNING FOREGROUND, download data will take a while." preferredStyle:UIAlertControllerStyleAlert];
  168. //block代码块取代了delegate
  169. UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  170. [appDelegate check_offline:ver useInternalAddress:self.switch_internal_address.isOn parentvc:self];
  171. // SyncControlPanelViewController * syncVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"SyncControlPanelViewController"];
  172. // syncVC.action_string=@"Download";
  173. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:syncVC] ;
  174. //
  175. //
  176. //
  177. //
  178. //
  179. // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  180. //
  181. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  182. // [self presentViewController:navi animated:YES completion:^{
  183. //
  184. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  185. //
  186. // DebugLog(@"about present.........");
  187. //
  188. // // self.btop = false;
  189. // // <#code#>
  190. // }];
  191. }];
  192. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  193. }];
  194. [alertControl addAction:actionTwo];
  195. [alertControl addAction:alertthree];
  196. [self presentViewController:alertControl animated:YES completion:nil];
  197. }
  198. }
  199. else
  200. {
  201. }
  202. }
  203. else
  204. {
  205. [RAUtils alert_view:@"Must login" title:@"Data sync"];
  206. }
  207. };
  208. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  209. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  210. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  211. [self presentViewController:navi animated:YES completion:^{
  212. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  213. DebugLog(@"LoginViewController present.........");
  214. // self.btop = false;
  215. // <#code#>
  216. }];
  217. }
  218. else
  219. {
  220. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  221. sqlite3* db = [iSalesDB get_db];
  222. int offline_user_iscurrent=[iSalesDB get_recordcount:db table:@"offline_login" where:[NSString stringWithFormat:@"username='%@'",appDelegate.user ]];
  223. [iSalesDB close_db:db];
  224. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  225. NSString* ver = [defaults stringForKey:@"OfflineVer"] ;
  226. if(offline_user_iscurrent==0 && ver!=nil)
  227. {
  228. if(!self.bunlock)
  229. {
  230. [RAUtils alert_view:@"Current login account is different from the offline account, to continue with sync, all current offline data will be erased, you must unlock offline lock first. " title:@"Sync denied."];
  231. return;
  232. }
  233. else
  234. {
  235. ver=nil;
  236. NSString *clearTableSQL = @"delete from offline_contact;delete from offline_order;delete from offline_cart;";
  237. [iSalesDB execSql:clearTableSQL];
  238. }
  239. } else if (ver && self.bunlock) {
  240. ver = nil;
  241. }
  242. if(sender==nil)
  243. {
  244. [appDelegate check_offline:ver useInternalAddress:self.switch_internal_address.isOn parentvc:self];
  245. // SyncControlPanelViewController * syncVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"SyncControlPanelViewController"];
  246. // syncVC.action_string=@"Download";
  247. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:syncVC] ;
  248. //
  249. //
  250. //
  251. //
  252. //
  253. // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  254. //
  255. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  256. // [self presentViewController:navi animated:YES completion:^{
  257. //
  258. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  259. //
  260. // DebugLog(@"about present.........");
  261. //
  262. // // self.btop = false;
  263. // // <#code#>
  264. // }];
  265. }
  266. else
  267. {
  268. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Check offline update?" message:@"Please connect to WIFI network and plug charging cable, KEEP SCREEN ON AND KEEP APP RUNNING FOREGROUND, download data will take a while." preferredStyle:UIAlertControllerStyleAlert];
  269. //block代码块取代了delegate
  270. UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  271. [appDelegate check_offline:ver useInternalAddress:self.switch_internal_address.isOn parentvc:self];
  272. }];
  273. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  274. }];
  275. [alertControl addAction:actionTwo];
  276. [alertControl addAction:alertthree];
  277. [self presentViewController:alertControl animated:YES completion:nil];
  278. }
  279. }
  280. }
  281. - (void)onCloseClick:(UIButton *)sender {
  282. // if(self.onDismissVC)
  283. // self.onDismissVC();
  284. [self dismissViewControllerAnimated:true completion:nil];
  285. }
  286. - (void)didReceiveMemoryWarning {
  287. [super didReceiveMemoryWarning];
  288. // Dispose of any resources that can be recreated.
  289. }
  290. - (IBAction)onChangeOfflineSwitch:(id)sender {
  291. UIApplication * app = [UIApplication sharedApplication];
  292. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  293. if(self.switch_offline.isOn==false)
  294. {
  295. //disable offline
  296. if(appDelegate.bLogin)
  297. {
  298. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Sign out"];
  299. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  300. NSDictionary* return_json = [iSalesNetwork logout];
  301. dispatch_async(dispatch_get_main_queue(), ^{
  302. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  303. if([[return_json valueForKey:@"result"] intValue]==2)
  304. {
  305. [appDelegate Logout];
  306. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  307. [defaults removeObjectForKey:@"EnableOfflineMode"];
  308. [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
  309. [defaults synchronize];
  310. #ifdef OFFLINE_MODE
  311. appDelegate.offline_mode =self.switch_offline.isOn;
  312. #endif
  313. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  314. [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
  315. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  316. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  317. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  318. [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
  319. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  320. [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  321. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  322. [((MainViewController*)appDelegate.main_vc) switchToHome];
  323. }
  324. else
  325. {
  326. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
  327. }
  328. });
  329. });
  330. }
  331. else
  332. {
  333. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  334. [defaults removeObjectForKey:@"EnableOfflineMode"];
  335. [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
  336. [defaults synchronize];
  337. #ifdef OFFLINE_MODE
  338. appDelegate.offline_mode =self.switch_offline.isOn;
  339. #endif
  340. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  341. [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
  342. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  343. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  344. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  345. [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
  346. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  347. [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  348. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  349. [((MainViewController*)appDelegate.main_vc) switchToHome];
  350. }
  351. }
  352. else
  353. {
  354. bool haveofflineData=[OLDataProvider check_offlinedata];
  355. if(haveofflineData)
  356. {
  357. // have offline data
  358. if(appDelegate.bLogin)
  359. {
  360. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Sign out"];
  361. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  362. NSDictionary* return_json = [iSalesNetwork logout];
  363. dispatch_async(dispatch_get_main_queue(), ^{
  364. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  365. if([[return_json valueForKey:@"result"] intValue]==2)
  366. {
  367. [appDelegate Logout];
  368. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  369. [defaults removeObjectForKey:@"EnableOfflineMode"];
  370. [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
  371. [defaults synchronize];
  372. #ifdef OFFLINE_MODE
  373. appDelegate.offline_mode =self.switch_offline.isOn;
  374. #endif
  375. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  376. [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
  377. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  378. [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
  379. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  380. [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
  381. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  382. [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  383. [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
  384. [((MainViewController*)appDelegate.main_vc) switchToHome];
  385. }
  386. else
  387. {
  388. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
  389. }
  390. });
  391. });
  392. }
  393. }
  394. else
  395. {
  396. //no offline data download form server first.
  397. // restore switch state.
  398. [self.switch_offline setOn:!self.switch_offline.isOn];
  399. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Offline data not found, download it from server?" message:@"Please connect to WIFI network and plug charging cable, KEEP SCREEN ON AND KEEP APP RUNNING FOREGROUND, download data will take a while." preferredStyle:UIAlertControllerStyleAlert];
  400. //block代码块取代了delegate
  401. UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  402. [self OnCheckUpdate:nil];
  403. }];
  404. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  405. // [self.switch_offline setOn:false];
  406. //[RAUtils message_alert:@"No item in the cart" title:@"Offline" controller:self] ;
  407. }];
  408. [alertControl addAction:actionTwo];
  409. [alertControl addAction:alertthree];
  410. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  411. [self presentViewController:alertControl animated:YES completion:nil];
  412. }
  413. //
  414. // UIApplication * app = [UIApplication sharedApplication];
  415. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  416. //
  417. // NSString* ver = [defaults stringForKey:@"OfflineVer"] ;
  418. // //
  419. // // [appDelegate check_offline:ver];
  420. // // return;
  421. //
  422. // // if(ver.length==0)
  423. // {
  424. //
  425. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Check offline update?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  426. // //block代码块取代了delegate
  427. //
  428. //
  429. // UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  430. // // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Checking offline data"];
  431. // //init offline mode
  432. // // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  433. // //
  434. // //
  435. // // // [self check_offline];
  436. // // });
  437. // [appDelegate check_offline:ver];
  438. //
  439. //
  440. //
  441. // }];
  442. //
  443. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  444. // // [self.switch_offline setOn:false];
  445. // //[RAUtils message_alert:@"No item in the cart" title:@"Offline" controller:self] ;
  446. // }];
  447. //
  448. // [alertControl addAction:actionTwo];
  449. // [alertControl addAction:alertthree];
  450. //
  451. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  452. //
  453. //
  454. // [self presentViewController:alertControl animated:YES completion:nil];
  455. //
  456. //
  457. //
  458. //
  459. //
  460. //
  461. //
  462. //
  463. // }
  464. // else
  465. // {
  466. //
  467. // }
  468. }
  469. }
  470. -(void) download_file:(NSString*)url type:(NSString*)type
  471. {
  472. }
  473. /*
  474. #pragma mark - Navigation
  475. // In a storyboard-based application, you will often want to do a little preparation before navigation
  476. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  477. // Get the new view controller using [segue destinationViewController].
  478. // Pass the selected object to the new view controller.
  479. }
  480. */
  481. @end