// // AppDelegate.m // goodpk // // Created by 歐特儀 on 2020/2/11. // Copyright © 2020 Altob. All rights reserved. // #import "AppDelegate.h" @interface AppDelegate () @property NSUserDefaults* defaults; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; } #pragma mark - UISceneSession lifecycle - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; } - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } - (void)applicationDidBecomeActive:(UIScene *)scene { // Called when the scene has moved from an inactive state to an active state. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. self.defaults = [NSUserDefaults standardUserDefaults]; if ([self.defaults boolForKey:@"notFirstRun"]) { [self.window.rootViewController dismissViewControllerAnimated:YES completion:NULL]; } } - (void)applicationWillResignActive:(UIScene *)scene { // Called when the scene will move from an active state to an inactive state. // This may occur due to temporary interruptions (ex. an incoming phone call). self.defaults = [NSUserDefaults standardUserDefaults]; if ([self.defaults boolForKey:@"notFirstRun"]) { UIViewController *blankViewController = [UIViewController new]; blankViewController.view.backgroundColor = [UIColor blackColor]; [self.window.rootViewController presentViewController:blankViewController animated:YES completion:NULL]; } } - (void)applicationDidEnterBackground:(UIApplication *)application { self.defaults = [NSUserDefaults standardUserDefaults]; if ([self.defaults boolForKey:@"notFirstRun"]) { UIViewController *blankViewController = [UIViewController new]; blankViewController.view.backgroundColor = [UIColor blackColor]; [self.window.rootViewController presentViewController:blankViewController animated:YES completion:NULL]; } } - (void)applicationWillEnterForeground:(UIApplication *)application { self.defaults = [NSUserDefaults standardUserDefaults]; if ([self.defaults boolForKey:@"notFirstRun"]) { [self.window.rootViewController dismissViewControllerAnimated:YES completion:NULL]; } } @end