728x90
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let vc = ViewController()
let navVC = UINavigationController(rootViewController: vc)
navVC.isNavigationBarHidden = true
window?.rootViewController = navVC
window?.makeKeyAndVisible()
print("application didFinishLaunchingWithOptions")
printState()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
let token = tokenParts.joined()
//print("Device Token: \(token)")
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Fail to register token \(error.localizedDescription)")
}
func applicationWillEnterForeground(_ application: UIApplication) {
print("applicationWillEnterForeground")
printState()
}
func applicationDidBecomeActive(_ application: UIApplication) {
print("applicationDidBecomeActive")
printState()
}
func applicationWillResignActive(_ application: UIApplication) {
print("applicationWillResignActive")
printState()
}
func applicationDidEnterBackground(_ application: UIApplication) {
print("applicationDidEnterBackground")
printState()
}
private func printState() {
switch UIApplication.shared.applicationState {
case .active:
print("state: active")
case .background:
print("state: background")
case .inactive:
print("state: inactive")
}
}
}
1. App Launch
- inactive -> active
2. Foreground -> Background
- active -> inactive -> background
3. Background -> Foreground
- (suspended) -> background -> inactive -> active
4. Go to App switcher
- active -> inactive
5. User exit the app by app switcher
- active -> inactive -> background -> not running
728x90
'iOS > 설명' 카테고리의 다른 글
[iOS] CALayer mask (0) | 2022.07.02 |
---|---|
[iOS] application(_:open:options:) 의 return 값은 어디서 사용되는가? (0) | 2022.06.25 |
[iOS] 앱 실행 시 UI Restoration Process (0) | 2022.06.06 |
[iOS] App launch Sequence (0) | 2022.06.06 |
[iOS] CFGetRetainCount (0) | 2022.06.02 |
댓글