Skip to content

Instantly share code, notes, and snippets.

@duraiganesh0
Created June 24, 2016 07:39
Show Gist options
  • Save duraiganesh0/22b136586323a970939e1d2edf415b6a to your computer and use it in GitHub Desktop.
Save duraiganesh0/22b136586323a970939e1d2edf415b6a to your computer and use it in GitHub Desktop.
import UIKit
import AWSCore
import GoogleMaps
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let defaults = NSUserDefaults.standardUserDefaults()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
// for storing the current User
GMSServices.provideAPIKey("AIzaSyC3bLplA68OFsiQK-ARkqHdOyZk56pXD2A")
let dict = Dictionary<String,AnyObject>()
NSUserDefaults.standardUserDefaults().registerDefaults(dict)
UIApplication.sharedApplication().statusBarStyle = .LightContent
// Use Firebase library to configure APIs
FIRApp.configure()
self.initializeWindow()
self.createInititalViewController()
let credentialProvider = AWSStaticCredentialsProvider(accessKey: access_key, secretKey: secret_access_key)
let defaultConfiguration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: credentialProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultConfiguration
return true
}
func applicationWillResignActive(application: UIApplication) {
// 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.
}
func applicationDidEnterBackground(application: UIApplication) {
// 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.
}
func applicationWillEnterForeground(application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(application: UIApplication) {
// 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.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func initializeWindow ()
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
}
func showRoot(viewController : UIViewController)
{
UIApplication.sharedApplication().statusBarHidden = true
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()
}
func createInititalViewController() {
if let userLogged = defaults.objectForKey("isUserLoggedIn")
{
if userLogged as! NSObject == 1 {
self.showRoot(Utils.setInitialViewToFeed())
} else {
let landingPageViewController:LoginViewController = getMainStoryBoard().instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
let navController:UINavigationController = UINavigationController(rootViewController: landingPageViewController)
self.window!.rootViewController = navController
navController.setNavigationControllerProperties()
self.showRoot(navController)
}
}
else
{
let landingPageViewController:LoginViewController = getMainStoryBoard().instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
let navController:UINavigationController = UINavigationController(rootViewController: landingPageViewController)
navController.setNavigationControllerProperties()
self.window!.rootViewController = navController
self.showRoot(navController)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment