IntroViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // IntroViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 9/16/15.
  6. // Copyright (c) 2015 Jason Lee. All rights reserved.
  7. //
  8. #import "RequestHandler.h"
  9. #import "IntroViewController.h"
  10. @interface IntroViewController () {
  11. }
  12. @end
  13. #pragma mark - Class Definition
  14. @implementation IntroViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. [self initUI];
  19. NSLog(@"%s\n applicationState = %zd", __PRETTY_FUNCTION__, [UIApplication sharedApplication].applicationState);
  20. if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) {
  21. [self prepareViewDidLoad];
  22. }
  23. }
  24. - (void)initUI {
  25. NSString *test = @"test";
  26. NSLog(@"%s\n %@", __PRETTY_FUNCTION__, test);
  27. DDLogError(@"test colors");
  28. }
  29. - (void)prepareViewDidLoad {
  30. }
  31. - (void)viewDidAppear:(BOOL)animated {
  32. [super viewDidAppear: animated];
  33. [self performSelector:@selector(requestVersionInfo) withObject:nil afterDelay:0.0f];
  34. //
  35. //#ifndef PRODUCT_MODE
  36. //
  37. // ServerPopTableView *spopup = [[ServerPopTableView alloc] initFromNib];
  38. // [spopup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  39. // if (buttonIndex == 0) {//OK
  40. // [self performSelector:@selector(requestVersionInfo) withObject:nil afterDelay:0.0f];
  41. // }
  42. // }];
  43. //
  44. //#else
  45. //
  46. // [self performSelector:@selector(requestVersionInfo) withObject:nil afterDelay:0.0f];
  47. //#endif
  48. }
  49. #pragma mark - Main Logic
  50. #pragma mark - Main Logic
  51. - (void)requestVersionInfo {
  52. //parameters
  53. NSDictionary *parameter = @{@"os_type": MOBILE_DEVICE_TYPE,
  54. @"store_code": APPSTORE_TYPE,
  55. @"app_version": [CommonUtil applicationShortVersion]};
  56. NSString *path = [NSString stringWithFormat:API_GET_APP_VERSION];
  57. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  58. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  59. return;
  60. }
  61. JDJSONModel *result = (JDJSONModel *) responseObject;
  62. if (result) {//API 성공 ,
  63. if ([result.resultCode isEqualToString:@"99"]) {//사용불가
  64. //앱 업그레이드 유도
  65. [[JDFacade facade] alert:MSG_ALERT_APP_UPDATE completionHander:^{
  66. NSString *appURL = URL_APP_UPDATE;
  67. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
  68. }];
  69. } else {
  70. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  71. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"LoginViewController" storyboardName:@"Main"];
  72. [JDFacade facade].appDelegate.window.rootViewController = vc;
  73. });
  74. }
  75. }
  76. } failure:^(id errorObject) {
  77. JDErrorModel *error = (JDErrorModel *)errorObject;
  78. [[JDFacade facade] alert:error.errorMessage];
  79. }];
  80. }
  81. #pragma mark - UI Events
  82. #pragma mark - MemoryWarning
  83. - (void)didReceiveMemoryWarning
  84. {
  85. [super didReceiveMemoryWarning];
  86. // Dispose of any resources that can be recreated.
  87. }
  88. @end