I've built a bare application with no functionality in XCode, and put logging statements in the applicationDidBecomeActive and applicationWillResignActive methods.
When I swipe down to show the notification center, I see the following:
2018-01-03 10:18:16.867028+0000 BareProject[1165:2053601] Resigning active
2018-01-03 10:18:17.510713+0000 BareProject[1165:2053601] Active
2018-01-03 10:18:17.634805+0000 BareProject[1165:2053601] Resigning active
Is this intended? My code does quite a lot of work when becoming active, only to have the rug pulled out from it again about 120ms later, and it seems that the documentation says I should be using applicationDidBecomeActive to restart tasks: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622956-applicationdidbecomeactive?language=objc
I tried this on ios 10.3 and this behavior does not exist.
There are actually two issues, the unexpected call to applicationDidBecomeActive:
and the duplicated call to applicationWillResignActive:
.
"Pull down" to show a notification center used to work properly on iOS 9. Only applicationWillResignActive:
used to be called by the system, just verified it with iOS 9 Simulator.
On iOS 11.2.6, the applicationDidBecomeActive:
gets called as you described which seems like an Apple bug. In this particular case, the system behavior conflicts with the documentation. Here is another example where the documentation deviates from the behavior you observed https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforHandlingAppStateTransitions/StrategiesforHandlingAppStateTransitions.html#//apple_ref/doc/uid/TP40007072-CH8-SW10
When your app is moved back to the active state, its applicationDidBecomeActive: method should reverse any of the steps taken in the applicationWillResignActive: method.
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