Nextrek
@ 556
Nextrek / iOS / SafariArte / trunk / SafariArte / AppDelegate.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
// // AppDelegate.m // SafariArte // // Created by Fabrizio on 27/04/15. // Copyright (c) 2015 Nextrek. All rights reserved. // #import "AppDelegate.h" #import "SFAUser.h" #import "LoginVC.h" #import "MenuVC.h" #import "RoutesVC.h" #import "HomeVC.h" #import <FBSDKCoreKit/FBSDKCoreKit.h> #import <FBSDKLoginKit/FBSDKLoginKit.h> #import "RFRateMe.h" #import "TutorialViewController.h" #import <Fabric/Fabric.h> #import <Crashlytics/Crashlytics.h> @interface AppDelegate () @end @implementation AppDelegate @synthesize viewController = _viewController; - (void) initUser { DATAMANAGER.user = [[SFAUser alloc] init]; DATAMANAGER.user.percorsi = [NSMutableDictionary dictionary]; DATAMANAGER.user.poiForRoute = [NSMutableDictionary dictionary]; DATAMANAGER.user.pointsForRoute = [NSMutableDictionary dictionary]; DATAMANAGER.user.timeForRoute = [NSMutableDictionary dictionary]; DATAMANAGER.user.credits = [NSNumber numberWithInt:0]; DATAMANAGER.user.cluesForRoute = [NSMutableDictionary dictionary]; [DATAMANAGER saveUser]; } - (void) setupNavigationBar:(UINavigationController*)nc { nc.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [nc.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; nc.navigationBar.shadowImage = [UIImage new]; nc.navigationBar.translucent = YES; nc.view.backgroundColor = [UIColor clearColor]; nc.navigationBar.backgroundColor = [UIColor clearColor]; nc.navigationBar.tintColor = [UIColor whiteColor]; [nc.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; } - (void) initWithMenu { HomeVC *viewController = [[HomeVC alloc] init]; MenuVC *viewController2 = [[MenuVC alloc] init]; self.nc = [[UINavigationController alloc] initWithRootViewController:viewController]; [self setupNavigationBar:self.nc]; SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:viewController2 frontViewController:self.nc]; // [revealController setRearViewRevealWidth:[[UIScreen mainScreen] bounds].size.width]; self.viewController = revealController; [self.window setRootViewController:self.viewController]; [self.window makeKeyAndVisible]; } - (void) initWithLogin { LoginVC *viewController = [[LoginVC alloc] init]; self.nc = [[UINavigationController alloc] initWithRootViewController:viewController]; [self setupNavigationBar:self.nc]; self.window.rootViewController = self.nc; [self.window makeKeyAndVisible]; } - (void) initWithTutorial { TutorialViewController *viewController = [[TutorialViewController alloc] init]; self.nc = [[UINavigationController alloc] initWithRootViewController:viewController]; [self setupNavigationBar:self.nc]; self.window.rootViewController = self.nc; [self.window makeKeyAndVisible]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:2 * 1024 * 1024 diskCapacity:150 * 1024 * 1024 diskPath:nil]; [NSURLCache setSharedURLCache:URLCache]; NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0]; [[NSUserDefaults standardUserDefaults] setObject:language forKey:@"lang"]; [[NSUserDefaults standardUserDefaults] synchronize]; if(![[NSUserDefaults standardUserDefaults] objectForKey:@"uuid"]) { NSString *uuid = [[UIDevice currentDevice] identifierForVendor].UUIDString; NSLog(@"UUID: %@", uuid); [[NSUserDefaults standardUserDefaults] setObject:uuid forKey:@"uuid"]; [[NSUserDefaults standardUserDefaults] synchronize]; } [DATAMANAGER loadUser]; NSLog(@"USER LANG: %@", DATAMANAGER.user.language ? DATAMANAGER.user.language : @"nil"); NSLog(@"DEVICE LANG: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"lang"]); if(!DATAMANAGER.user) { [self initUser]; } [DATAMANAGER defineLanguage]; BOOL sameLang; if(DATAMANAGER.user.language) { NSString *devLanguage = [[NSUserDefaults standardUserDefaults] objectForKey:@"lang"]; NSString *userLanguage = DATAMANAGER.user.language; sameLang = [userLanguage containsString:devLanguage]; } else { sameLang = NO; } if ([[NSUserDefaults standardUserDefaults] boolForKey:@"isLogged"] && sameLang) { [self initWithMenu]; } else { [self initWithLogin]; } [RFRateMe showRateAlertAfterTimesOpened:3]; [Fabric with:@[CrashlyticsKit]]; return YES; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end |
Commits for Nextrek/iOS/SafariArte/trunk/SafariArte/AppDelegate.m
Revision | Author | Commited | Message |
---|---|---|---|
556 Diff | FAquili | Tue 25 Aug, 2015 10:35:23 +0000 | last update |
502 Diff | FPompili | Thu 13 Aug, 2015 13:53:08 +0000 | aggiunto salavataggio img offline con la routebyID |
446 Diff | PBonamassa | Wed 29 Jul, 2015 14:07:14 +0000 | added tutorial VC |
385 Diff | FPompili | Fri 17 Jul, 2015 14:45:51 +0000 | added auto conversion km->mile |
369 Diff | FPompili | Thu 16 Jul, 2015 16:57:38 +0000 | added cluesdictionary , fixed something |
363 Diff | FAquili | Thu 16 Jul, 2015 15:13:30 +0000 | classifica URL inserted |
342 Diff | FAquili | Wed 15 Jul, 2015 12:53:24 +0000 | purchase flow |
341 Diff | FAquili | Wed 15 Jul, 2015 10:17:54 +0000 | bug fixing |
338 Diff | PBonamassa | Wed 15 Jul, 2015 09:39:56 +0000 | added local viewSettings |
308 | FPompili | Mon 13 Jul, 2015 15:54:46 +0000 | added RFAlert |