I have an app that must stay awake until the end of a countdown but it will go into 'sleep mode' whenever it reaches the allocated time to sleep.
In my app, I have the option to postpone sleep, so users can disable/enable it.
How do I do it programmatically?
You can disable the idle timer as follows;
[UIApplication sharedApplication].idleTimerDisabled = YES;
UIApplication.sharedApplication().idleTimerDisabled = true
Set it back to
false to re-enable sleep mode.
More about UIApplication Class.