If you are ready to get your hands on it, it can be quite easy to fix by making the Cordova plugin.
If you havenβt created the Cordova plugin, this is definitely a skill that you must master, since not all functions are available through PhoneGap plugins, and it is often quite easy to get it working. Full details can be found in the PhoneGap Plugin Development Guide .
To do this, your JavaScript side in the plugin will be something like
cordova.exec(function(winParam) {}, function(error) {}, "myPlugin", "preventSleep", []);
In this case, your PhoneGap will look for a method called preventSleep in the myPlugin class.
Next, your preventSleep method will look something like
- (void)preventSleep:(CDVInvokedUrlCommand*)command { [UIApplication sharedApplication].idleTimerDisabled = YES; CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }
Now you can make an appropriate method, for example allowSleep , which sets [UIApplication sharedApplication].idleTimerDisabled = NO;
source share