iPhone app running while screen locked

David picture David · Nov 19, 2009 · Viewed 11.2k times · Source

Here is something I am trying desperately to get to work:

I have an app that polls the GPS module in specified intervals and then sends out coords out to a server using Unix calls such as write(); It works fine when the app is active, but once the screen locks itself, reporting stops.

I have found this: [UIApplication sharedApplication].idleTimerDisabled = YES; This does keep the app alive, but also rapidly discharges the battery. I came across other apps that stream music even when the screen is locked (non-Apple apps) and thus I figured there has to be a way to keep the GPS data stream alive.

Can anyone assist? Thank you!

Answer

tddmonkey picture tddmonkey · Feb 8, 2010

Have a look at this:

http://marcopeluso.com/2009/08/23/how-to-prevent-iphone-from-deep-sleeping/

It's a drop in piece of code used to disable deep sleep. Your screen can still shut off while your application continues to run in the background.