// // AppDelegate+GiGaConfig.m // GIGA // #import "AppDelegate+GiGaConfig.h" #import "GiGaServerConfig.h" #import "GiGaUserViewController.h" #import "GiGaBaseNavViewController.h" #import "GiGaMaskTaskViewController.h" #import "GiGaUserDefault.h" #import "GiGaStartAdView.h" #import #import "GiGaLocalNotificationManager.h" @implementation AppDelegate (GiGaConfig) -(void)setupTabBarController{ // GiGaExercisesViewController *exerciseVC = [[GiGaExercisesViewController alloc] init]; // GiGaBaseNavViewController *exerciseNav =[[GiGaBaseNavViewController alloc] initWithRootViewController:exerciseVC]; // exerciseNav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; // exerciseNav.title = @"测试"; // exerciseNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"测试" // image:nil // selectedImage:nil]; GiGaMaskTaskViewController *maskVC = [[GiGaMaskTaskViewController alloc] init]; GiGaBaseNavViewController *maskNav =[[GiGaBaseNavViewController alloc] initWithRootViewController:maskVC]; maskNav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; maskNav.title = @"测试2"; maskNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"测试2" image:nil selectedImage:nil]; GiGaUserViewController *userVC = [[GiGaUserViewController alloc] init]; GiGaBaseNavViewController *userNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userVC]; userNav.navigationBar.titleTextAttributes =@{NSForegroundColorAttributeName:[UIColor blackColor]}; userNav.title = @"我的"; userNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:nil selectedImage:nil]; [[UITabBar appearance] setTintColor:GIGARGB(70, 70, 70, 1)]; self.rootTabBarVC = [[UITabBarController alloc] init]; self.rootTabBarVC.viewControllers = @[maskNav,userNav]; [self initTabItems]; self.window.rootViewController = self.rootTabBarVC; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; } -(void)initTabItems{ UITabBar *tabBar = self.rootTabBarVC.tabBar; UITabBarItem *item0 = [tabBar.items objectAtIndex:0]; UITabBarItem *item1 = [tabBar.items objectAtIndex:1]; UITabBarItem *item2 = [tabBar.items objectAtIndex:2]; item0.selectedImage = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; ; item0.image = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item1.selectedImage = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; ; item1.image = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item2.selectedImage = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; ; item2.image = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; } -(void)configEnvironment{ [GiGaServerConfig setServerType:GIGA_ENVIRONMENT]; } - (void)setupRootVC{ GiGaMaskTaskViewController *maskeVC = [[GiGaMaskTaskViewController alloc] init]; GiGaBaseNavViewController *maskNav =[[GiGaBaseNavViewController alloc] initWithRootViewController:maskeVC]; maskNav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]}; [maskeVC addNavTitile:GIGALocalComm(@"masktime_nav_title")]; self.window.rootViewController = maskNav; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; } -(void)creatAdView{ GiGaStartAdView *startadview = [[GiGaStartAdView alloc] initWithFrame:self.window.bounds]; [startadview show]; } -(void)registLocalNotification{ if (@available(iOS 10.0, *)) { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) { }]; } else { // Fallback on earlier versions UIUserNotificationSettings *setings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert categories:nil]; //授权 [[UIApplication sharedApplication] registerUserNotificationSettings:setings]; } } //接收本地通知 ios 8 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if ([[[UIDevice currentDevice] systemVersion] floatValue] >=8.0 && [[[UIDevice currentDevice] systemVersion] floatValue] <10.0) { [[GiGaLocalNotificationManager localNotifiationCenter] didResaveloaclNitification:notification]; } } @end