(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (application.applicationState == UIApplicationStateBackground) {
// ✅ Background launch
} else {
// ✅ Normal foreground launch
}
}
Previously, when using AppDelegate to handle lifecycle methods, I could determine whether a cold start was a background launch as shown above. This allowed me to accurately measure cold start time for real-world users.
The platform now requires migration to scene-based lifecycle management by iOS 16. However, after migration:
In both application:didFinishLaunchingWithOptions: and scene:willConnectToSession:options: methods,
application.applicationState == UIApplicationStateBackground and scene.activationState == UISceneActivationStateUnattached
These values remain fixed regardless of whether it's a background launch, making them unusable for differentiation.
I attempted to use information from UISceneConnectionOptions for distinction but found it ineffective.
Question: Are there alternative approaches to achieve this distinction?
1
0
140