When I launch my app on iOS 10, I can see that after a short delay, the Appdelegate function -> applicationWillResignActive() is called. There is no reason for that. The app is still active and in foreground state when it occurs and the app continues to run normally.
Please see above the lifecycle of my app :
--> Click on the app icon
This sequence is repeated each time I open the app.
It looks as if something forces my app to quit the foreground state for an ultra short delay. Usually, applicationDidBecomeActive is called when the app displays an alert ( for example if the app requires an user's permission to access the camera ) or when the user clicks on the home button.
1 - It only occurs when the app starts in landscape mode
2 - It only occurs on iPhones and not on iPads
3 - The problem does NOT occur on an iOS 9 device
Did anyone noticed this problem ?
The problem is, it calls second time after dismissing system services alert (location, push notifications, photos)
So the only way to handle it is to use variable in AppDelegate which increments each time some system alert shows and decrements in applicationDidBecomeActive
, so you call your code only if value of this variable is 1.
Another interesting thing is that applicationDidEnterBackground
doesn't call when system alert shows, thus we can use this info to decide whether we should call our code in applicationDidBecomeActive
or not (but still, it can be less reliable solution)
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