Preventing the iPhone from going to sleep!

If you have an application that requires the iPhone from going to sleep when the user is not touching the screen or otherwise interacting with the iPhone, you need to disable the idle timer.
This is very easily done in code, but remember, it does use up more battery life, so the idle timer should only [...]

If you have an application that requires the iPhone from going to sleep when the user is not touching the screen or otherwise interacting with the iPhone, you need to disable the idle timer.

This is very easily done in code, but remember, it does use up more battery life, so the idle timer should only be disabled when it’s absolutely necessary!!

The code can be put in a variety of places, but I would recommend placing it in the ProjectNameAppDelegate.m file, inside the applicationDidFinishLaunching method as follows;

-(void)applicationDidFinishLaunching:(UIApplication *)application
{
//Code to stop the iPhone from sleeping
[[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ];
}

Don’t forget that this will drain the battery more, so use it only when it’s essential!
Happy coding!

Cheers
Graham

Tagged with:
 

2 Responses to “Preventing the iPhone from going to sleep!”

  1. Daryl Vanwhy says:

    Cool work, hope to hear more from you.Are you working in a Group that you can make such a cool Blog?

Leave a Reply




Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!