So, I was looking for a way to keep the user’s iPhone display on for a clock app. I found [UIApplication sharedApplication].idleTimerDisabled = YES; but that keeps the device from locking all of the time. I tried to [UIApplication sharedApplication].idleTimerDisabled = NO; when the application goes into the background, but that doesn’t work. How can I safely keep the user’s device from sleeping while my app is running?
So, I was looking for a way to keep the user’s iPhone display on
Share
Alter the
idleTimerDisabledproperty whenever your app changes its active state – if you’re going to be backgrounded, re-enable the timer, and when you regain control, disable the timer again.