I’m trying to keep the iphone screen on while my app’s running. I followed this post:
phonegap, iphone and the big bad idleTimerDisabled
and did something like this in PhoneGapDelegate.m:
-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// existing code ...
application.idleTimerDisabled = YES; // I added this line
return YES; // existing code
}
but it didn’t work.
I also tried this approach: http://groups.google.com/group/phonegap/browse_thread/thread/5eeace5c416719ec/d7180ef5a3a9081d?lnk=gst&q=lock#d7180ef5a3a9081d
but it didn’t work either.
Could anybody give me some suggestions? Thank you!
UPDATE: Thank you all! It turns out I was changing the wrong fil(PhoneGapDelegate.m). applicationdidfinishlaunching method in that file is never invoked. The file to be changed is AppDlegate.m.
According to this question: iOS: How to stop the device standby timer? all you need to do is:
Be sure you add this before the
return YES;line to be sure it executes.Apple recommends you only use this as-needed:
However
According to this post: Phonegap, iphone – applicationDidFinishLaunching not invoking PhoneGap does not call this function, due to the Xcode project file.
Based on what the answers say, I would try implementing the following function as well, into your app delegate: