Is applicationWillEnterForeground always called after applicationDidEnterBackground?

535 views Asked by At

I am trying to figure out some logic in my iOS application delegate. I want to perform some actions in applicationDidEnterBackground and undo them in applicationWillEnterForeground, as suggested. But I want to make sure that, unless the app is terminated, applicationWillEnterForeground is always called after applicationDidEnterBackground. I know that this is generally the case, but I know that there are always fringe cases (authorizations, other interruptions like phone calls, notifications). I think that I have checked most cases and found that applicationWillEnterForeground will always be called to counter applicationDidEnterBackground but I want to see if there are any cases that I am missing where this is not the case.

1

There are 1 answers

5
Christopher Shireman On

Set a Boolean value in the user defaults when you enter the background. Then, when you re-enter the foreground check the value of that Boolean to determine whether or not it was set properly. Either way, always set the Boolean to false when returning to the foreground.