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
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 varibale in AppDelegate which incremetns each time some system alert shows and decremants 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)