summaryrefslogtreecommitdiff
path: root/plugins/nl.x-services.plugins.insomnia/src/ios
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/nl.x-services.plugins.insomnia/src/ios')
-rwxr-xr-xplugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.h9
-rwxr-xr-xplugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.m32
2 files changed, 41 insertions, 0 deletions
diff --git a/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.h b/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.h
new file mode 100755
index 00000000..c13c07ba
--- /dev/null
+++ b/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.h
@@ -0,0 +1,9 @@
+#import <Cordova/CDV.h>
+
+@interface Insomnia :CDVPlugin
+
+- (void) keepAwake:(CDVInvokedUrlCommand*)command;
+
+- (void) allowSleepAgain:(CDVInvokedUrlCommand*)command;
+
+@end
diff --git a/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.m b/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.m
new file mode 100755
index 00000000..7eca3b07
--- /dev/null
+++ b/plugins/nl.x-services.plugins.insomnia/src/ios/Insomnia.m
@@ -0,0 +1,32 @@
+#import "Insomnia.h"
+#import <Cordova/CDV.h>
+
+@implementation Insomnia
+
+- (void) keepAwake:(CDVInvokedUrlCommand*)command {
+ NSString *callbackId = command.callbackId;
+
+ // Acquire a reference to the local UIApplication singleton
+ UIApplication* app = [UIApplication sharedApplication];
+
+ if (![app isIdleTimerDisabled]) {
+ [app setIdleTimerDisabled:true];
+ }
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:result callbackId:callbackId];
+}
+
+- (void) allowSleepAgain:(CDVInvokedUrlCommand*)command {
+ NSString *callbackId = command.callbackId;
+
+ // Acquire a reference to the local UIApplication singleton
+ UIApplication* app = [UIApplication sharedApplication];
+
+ if([app isIdleTimerDisabled]) {
+ [app setIdleTimerDisabled:false];
+ }
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:result callbackId:callbackId];
+}
+
+@end \ No newline at end of file