Is there any notification I can listen to that will alert me that the phone will go to sleep? I have implemented the following:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(resignActive:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
but it seems that it's not getting triggered when the phone goes to sleep after some time of inactivity (1 min in my settings). The reason I think it's not working is that I have a timer that perform an action every second and if a certain time has passed (bigger than one minute) it issues an audio alarm. In my resignActive I invalidate my timer and that works fine when I press the home button, but not when the phone goes to sleep. It still seems to be running in the background but "at a lower speed" as the times are much longer than normal (around 10 min instead of 2 min).
Any ideas what's happening when the phone goes to sleep? I have read these two posts but it doesn't really answer my question.