In a scene-based UIKit app, which UISceneDelegate callbacks fire when a call screen is interrupted or backgrounded, and why don't the app delegate's equivalents fire?
answer
- one delegate per window, not per app
- inactive comes before background
- a system alert only resigns active
- the app switcher snapshot follows background
- iOS 26 deprecated the app delegate's four
basics
~10 sAn interruption calls sceneWillResignActive(:); going to the background calls sceneWillResignActive(:) then sceneDidEnterBackground(:); returning calls sceneWillEnterForeground(:) then sceneDidBecomeActive(_:). With scenes enabled UIKit calls these instead of the app delegate's methods, which iOS 26 deprecated.
solid answer
~40 sSince iOS 13 each window's life cycle is reported per scene, to that scene's `UISceneDelegate`. `sceneWillResignActive(_:)` fires for temporary interruptions, such as a system alert, and before going to the background: pause the call's outgoing video and timers there. `sceneDidEnterBackground(_:)` means the scene is off screen; free resources and stop the camera preview, and remember UIKit snapshots the window for the app switcher shortly after it returns. Coming back runs `sceneWillEnterForeground(_:)` then `sceneDidBecomeActive(_:)`. When scenes are enabled, UIKit calls these and not `applicationWillResignActive(_:)`, `applicationDidEnterBackground(_:)` and the other two; iOS 26 deprecated those four in favour of the scene life cycle or the `UIApplication` notifications.
code
swift · 29 linesimport UIKit
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func sceneWillResignActive(_ scene: UIScene) {
// Interruptions too: a call banner, Control Center, the app switcher.
callScreen(in: scene)?.muteOutgoingVideo()
}
func sceneDidEnterBackground(_ scene: UIScene) {
// This window is off screen; UIKit snapshots it shortly after this returns.
callScreen(in: scene)?.stopCameraPreview()
}
func sceneWillEnterForeground(_ scene: UIScene) {
callScreen(in: scene)?.startCameraPreview()
}
private func callScreen(in scene: UIScene) -> CallScreen? {
(scene as? UIWindowScene)?.keyWindow?.rootViewController as? CallScreen
}
}
final class CallScreen: UIViewController {
func muteOutgoingVideo() {}
func stopCameraPreview() {}
func startCameraPreview() {}
}go deeper
Name the four scene delegate callbacks in order for leaving and returning, and say that a system alert only resigns active.
Explain why app delegate active and background methods go silent once scenes are enabled, what iOS 26 deprecated, and what the app delegate still owns.
Route scene events to the right screen in multi-window iPad apps, scope notifications to one scene, and hide sensitive content before the app switcher snapshot.
Plan the move of legacy app delegate life cycle code into scene delegates, deciding which behaviour is per window and which stays app-wide.
## Scenes own the window life cycle From iOS 13 a UIKit app can run its interface in **scenes**: each `UIWindowScene` is one instance of the app's UI, and on iPad the user can have several open at once. Each scene has its own **scene delegate**, an object conforming to `UISceneDelegate` (in practice `UIWindowSceneDelegate`), named in the `Info.plist` scene manifest or in the `UISceneConfiguration` the app delegate returns from `application(_:configurationForConnecting:options:)`. A scene's `activationState` is one of `.unattached`, `.foregroundActive`, `.foregroundInactive` or `.background`, and the delegate hears about every move between them. ## The callbacks in order | Event | Callbacks, in order | |---|---| | Scene created and shown | `scene(_:willConnectTo:options:)`, `sceneWillEnterForeground(_:)`, `sceneDidBecomeActive(_:)` | | Temporary interruption (system alert) | `sceneWillResignActive(_:)`, later `sceneDidBecomeActive(_:)` | | User goes home or to another app | `sceneWillResignActive(_:)`, `sceneDidEnterBackground(_:)` | | User comes back | `sceneWillEnterForeground(_:)`, `sceneDidBecomeActive(_:)` | | Scene closed or reclaimed | `sceneDidDisconnect(_:)` | What each one is for, according to Apple's documentation: - **`sceneWillResignActive(_:)`**: quiet the interface. Pause ongoing tasks, disable timers, lower frame rates. For a call screen, pause outgoing video or show a paused state. It fires for interruptions that never reach the background, so it must be cheap to undo. - **`sceneDidEnterBackground(_:)`**: the scene is no longer on screen. Reduce memory, free shared resources, stop the camera preview. Shortly after it returns, UIKit takes a **snapshot** for the app switcher, so hide anything sensitive first. - **`sceneWillEnterForeground(_:)`** is always followed by **`sceneDidBecomeActive(_:)`**, where timers restart and content refreshes. - **`sceneDidDisconnect(_:)`**: the scene is being removed, either because the user closed it in the app switcher or because UIKit is reclaiming memory. It does **not** fire just because the user switched apps. The documentation also warns against saving data only in `sceneWillResignActive(_:)`; save at natural points such as when the user leaves a form. ## Why the app delegate stays silent The pages for the four foreground and background callbacks carry the same note: when scenes are enabled and the scene method is implemented, UIKit calls it and **does not call** the matching `UIApplicationDelegate` method. The four affected app delegate methods are `applicationDidBecomeActive(_:)`, `applicationWillResignActive(_:)`, `applicationDidEnterBackground(_:)` and `applicationWillEnterForeground(_:)`. A team that adds a scene manifest and leaves its pause-video code in `applicationWillResignActive(_:)` finds it never runs. In **iOS 26** those four are **deprecated**, with messages pointing to the scene life cycle or to `UIApplication.didBecomeActiveNotification` and its siblings, which remain available. Deprecated means a compiler warning, not removal. The app delegate still owns launch (`application(_:didFinishLaunchingWithOptions:)`), scene configuration and `application(_:didDiscardSceneSessions:)`, termination, and app-wide events such as `applicationDidReceiveMemoryWarning(_:)`. ## Mistakes that show up in review - **Pausing only in `sceneDidEnterBackground(_:)`.** A system alert or an incoming interruption leaves the scene in the foreground but inactive, so the call keeps sending video the user cannot see or control. Pause in `sceneWillResignActive(_:)` and resume in `sceneDidBecomeActive(_:)`. - **Releasing everything in `sceneWillResignActive(_:)`.** Because it also fires for brief interruptions, heavy teardown there makes every alert expensive to recover from. Keep the heavy release for `sceneDidEnterBackground(_:)`. - **Treating `sceneDidDisconnect(_:)` as the background callback.** It is a different, rarer event, and code waiting for it may never run. - **Leaving sensitive content visible.** The app switcher snapshot is taken shortly after `sceneDidEnterBackground(_:)` returns, so a blur or cover must be in place by then. - **Keeping life cycle code in the app delegate after adopting scenes.** The four active and background methods are silent once scenes are enabled. ## Reaching the call screen The scene delegate sees the window, not the screen. Two common ways to get the event to the call view controller: 1. The scene delegate finds the call screen from its window's root view controller and calls a method on it, as in the example. 2. The call screen observes `UIScene.willDeactivateNotification` and `UIScene.didEnterBackgroundNotification` with its own `view.window?.windowScene` as the object, so a second iPad window going to the background does not pause the call in this one. What the app should persist when it may be terminated in the background is a design question with its own material; this answer only covers which UIKit callbacks fire.
- In a UIKit app with two iPad windows, how does a call screen avoid pausing when the other window goes to the background?Each window is its own scene with its own delegate calls, so code in one scene delegate only hears its own scene. A view controller observing notifications should pass its own `view.window?.windowScene` as the `object` of `UIScene.didEnterBackgroundNotification`; observing the app-wide `UIApplication` notification, or a scene notification with a nil object, reacts to every scene.
- In UIKit, where does a memory warning arrive in a scene-based app?It is app-wide, not per scene. UIKit calls `applicationDidReceiveMemoryWarning(_:)` on the app delegate, posts `UIApplication.didReceiveMemoryWarningNotification`, and calls `didReceiveMemoryWarning()` on view controllers, whose overrides free rebuildable caches and call `super`. None of these memory-warning methods is deprecated.
- applicationDidEnterBackground(_:) still runs alongside the scene callbacks
- sceneDidDisconnect(_:) fires every time the user switches apps
- sceneWillResignActive(_:) only fires right before going to the background
- iOS 26 removed the app delegate's background callbacks entirely
- One scene delegate hears every window's life cycle
Assumes the iOS 27.1 SDK; scenes date from iOS 13, and iOS 26 deprecated the app delegate's active and background callbacks in favour of the scene life cycle.