diff options
Diffstat (limited to 'Juick/AppDelegate.m')
-rw-r--r-- | Juick/AppDelegate.m | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index d4c2304..47c18ef 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -6,11 +6,9 @@ // Copyright (c) 2013 com.juick. All rights reserved. // -#import "AppDelegate.h" #import "MessagesViewController.h" #import "LoginViewController.h" -#import "APIClient.h" #import "Message.h" #import "User.h" #import "DeviceRegistration.h" @@ -28,6 +26,10 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + self.api = [API new]; + self.sharedDateFormatter = [NSDateFormatter new]; + self.sharedDateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; + [self.sharedDateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; [[UINavigationBar appearance] setTintColor:[UIColor colorNamed:@"Title"]]; [[UINavigationBar appearance] setBarTintColor:[UIColor colorNamed:@"Background"]]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorNamed:@"Muted"]}]; @@ -36,8 +38,9 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; [[UITabBar appearance] setTintColor:[UIColor colorNamed:@"Title"]]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; - +#if !TARGET_IPHONE_SIMULATOR [self registerForRemoteNotifications]; +#endif NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; if (userInfo) { [self parseNotificationPayload:userInfo]; @@ -63,7 +66,7 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; DeviceRegistration *registration = [DeviceRegistration new]; registration.type = @"apns"; registration.token = token; - [[APIClient sharedClient] refreshDeviceRegistration:registration callback:^(BOOL success) { + [self.api refreshDeviceRegistration:registration callback:^(BOOL success) { if (success) { NSLog(@"successfully refreshed registration with %@", token); } @@ -156,4 +159,8 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated"; [[self navigator] performSegueWithIdentifier:@"loginSegue" sender:vc]; } +- (void)unauthorized { + [self presentLoginView:self.window.rootViewController]; +} + @end |