Can an app force the device to sleep?

iphone

Solution

Not in a public API. There may be something private but you wouldn't be able to use it in the app store. The only method I know of that deals with the sleep mode is being able to disable the sleep while your application is running:

[UIApplication sharedApplication].idleTimerDisabled = YES;

I think the idea is that software shouldn't be able to effect the hardware too much i.e. starting, sleeping quitting your application are not up to you and exit()ing your app manually through code would be a non-standard practice and frowned upon by Apple. The nice thing is that your phone will sleep by default after a short amount of time.

Problem

Is there anyway to put the iPhone into sleep mode from an app? If yes, how can I do that? Thanks, Tee

Original source