Is it just my app, or do all Mac apps made with Catalyst not undergo lifecycle changes except when launching or quitting?
Upon launch, the UIWindowSceneDelegate
methods sceneWillEnterForeground:
and sceneDidBecomeActive:
are called. When quitting sceneWillResignActive
and sceneDidEnterBackground
are called.
But these never take place when the app is left open and I change to a new app, or let my computer sleep, or do other normal human usage patterns that I would expect to force the app into the background state. I'm left with the impression that the app never leaves the foreground state as long as it is not quit by the user. Is this correct?
If I implement support for automatic or sudden termination (as detailed here), might the app enter/exit app states more frequently?
Is there something I am misunderstanding?
Thank you for any help.
(Note: I built a system that logs app transitions – rather 'scene' transitions – so as to be able to test without running the app in Xcode.)
In my case, a workaround helped:
#if targetEnvironment(macCatalyst)
nc.addObserver(self, selector: #selector(hold), name: NSNotification.Name("NSApplicationDidResignActiveNotification"),object: nil)
nc.addObserver(self, selector: #selector(resume), name: NSNotification.Name("NSApplicationDidBecomeActiveNotification"),object: nil)
#endif
Hopefully in the future there will be a more elegant option using UIScene.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With