Reputation: 23510
When registering the UIApplicationDidEnterBackgroundNotification, I notice that this notification is not triggered when the device enters in sleep mode.
But, when waking it up, the UIApplicationDidBecomeActiveNotification notification is triggered. It is also triggered when coming back from background mode.
So how can I know if my application comes back from background mode, or is activated following a wake up of the device ?
Upvotes: 3
Views: 2785
Reputation: 43472
Those don't balance each other; they are posted for unrelated events. I believe you want UIApplicationWillEnterForegroundNotification
when detecting your app coming back from the background, and UIApplicationWillResignActiveNotification
when detecting certain other situations (including sleep.)
Note that UIApplicationWillResignActiveNotification
also shows for events such as "incoming phone call was ignored" and "the operating system displayed an alert that is not part of your process" (e.g. a text message.)
Upvotes: 4