Ilya Loshkarev loshkarev.i@gmail.com
SFEDU 2018
Background task must be declared in app preferences
Controller
// Launch time
application(_: willFinishLaunchingWithOptions:)
application(_: didFinishLaunchingWithOptions:)
// Transitioning to the foreground
applicationDidBecomeActive(_:)
// Transitioning to the background
applicationDidEnterBackground(_:)
// Transitioning to the inactive state
applicationWillResignActive(_:) // from foreground
applicationWillEnterForeground(_:) // from background
// Termination
applicationWillTerminate(_:) // when not suspended
// If App should save or restore state
application(_:shouldSaveApplicationState:)
application(_:shouldRestoreApplicationState:)
// System Events
applicationDidReceiveMemoryWarning(_:)
applicationSignificantTimeChange(_:)
application(_:open:options:)
// Local Notifications
application(_:didReceive:)
// Remote Notifications
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
View
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// Create new UIWindow
var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Create root ViewController
window!.rootViewController = UIViewController()
// Set window to handle input and show it
window!.makeKeyAndVisible()
return true
}
}