Hello,
I’m currently working on migrating an existing AppDelegate-based application to use the scene-based life cycle, as recommended in the TN3187 technical note.
As part of this process, I’ve been conducting some tests. After completely removing the scene-based setup (i.e., removing the UIApplicationSceneManifest from Info.plist and deleting SceneDelegate.swift), the app runs in a legacy AppDelegate-only life cycle as expected. In this case, lifecycle methods such as applicationWillEnterForeground and applicationDidEnterBackground in the AppDelegate are called properly. SceneDelegate methods are, naturally, not called—since the class is removed.
However, here’s where the confusion arises: Even in this AppDelegate-only configuration, if I register for UIScene notifications via NotificationCenter, the corresponding selectors are invoked at runtime, which suggests that UIScene lifecycle notifications are still being broadcast internally by the system.
Below is the test code I used, along with console output:
func addObserver() {
NotificationCenter.default.addObserver(self, selector: #selector(appDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(sceneDidEnterBackground), name: UIScene.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(sceneWillEnterForeground), name: UIScene.willEnterForegroundNotification, object: nil)
}
}
@objc
func sceneWillEnterForeground() {
print("sceneWillForeground")
}
@objc
func sceneDidEnterBackground() {
print("sceneDidEnterBackground")
}
@objc
func appWillEnterForeground() {
print("appWillEnterForeground")
}
@objc
func appDidEnterBackground() {
print("appDidEnterBackground")
}
sceneWillForeground
AppDelegate::willenterforeground
appWillEnterForeground
So, my question is:
Even in an AppDelegate-only app running on iOS 13 or later, is it expected behavior that UIScene lifecycle notifications such as UIScene.didEnterBackgroundNotification and UIScene.willEnterForegroundNotification are still posted by the system?
===
Additional Question:
The TN3187 note lists only four methods to migrate between AppDelegate and SceneDelegate. Are there any other lifecycle methods (beyond the four listed) that also require manual migration during this transition?
Thank you in advance for your insights.