From f7ace39516f5e8412ac7f7871e997b16d12caa0b Mon Sep 17 00:00:00 2001 From: Matias Tucci Date: Mon, 16 May 2016 08:34:01 +0200 Subject: [PATCH] implement wrappers for Insomnia --- src/index.ts | 8 ++++--- src/plugins/insomnia.ts | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/plugins/insomnia.ts diff --git a/src/index.ts b/src/index.ts index 1d43e9c14..19e20c8f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,7 @@ import {GoogleAnalytics} from './plugins/googleanalytics'; import {Hotspot} from './plugins/hotspot'; import {ImagePicker} from './plugins/imagepicker'; import {InAppBrowser} from './plugins/inappbrowser'; +import {Insomnia} from './plugins/insomnia'; import {Keyboard} from './plugins/keyboard'; import {LaunchNavigator} from './plugins/launchnavigator'; import {LocalNotifications} from './plugins/localnotifications'; @@ -93,6 +94,7 @@ export { Hotspot, ImagePicker, InAppBrowser, + Insomnia, Keyboard, LaunchNavigator, LocalNotifications, @@ -104,7 +106,7 @@ export { SocialSharing, SpinnerDialog, Splashscreen, - SQLite, + SQLite, StatusBar, Toast, TouchID, @@ -146,7 +148,7 @@ window['IonicNative'] = { Flashlight: Flashlight, Geolocation: Geolocation, Globalization: Globalization, - GoogleMaps : GoogleMaps, + GoogleMaps : GoogleMaps, GoogleAnalytics: GoogleAnalytics, Hotspot: Hotspot, ImagePicker: ImagePicker, @@ -162,7 +164,7 @@ window['IonicNative'] = { SocialSharing: SocialSharing, SpinnerDialog: SpinnerDialog, Splashscreen: Splashscreen, - SQLite: SQLite, + SQLite: SQLite, StatusBar: StatusBar, Toast: Toast, TouchID: TouchID, diff --git a/src/plugins/insomnia.ts b/src/plugins/insomnia.ts new file mode 100644 index 000000000..95238a666 --- /dev/null +++ b/src/plugins/insomnia.ts @@ -0,0 +1,47 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name Insomnia + * @description + * Prevent the screen of the mobile device from falling asleep. + * + * @usage + * ```js + * import {Insomnia} from 'ionic-native'; + * + * Insomnia.keepAwake() + * .then( + * () => console.log('success'), + * () => console.log('error') + * ); + * + * Insomnia.allowSleepAgain() + * .then( + * () => console.log('success'), + * () => console.log('error') + * ); + * ``` + * + */ +@Plugin({ + plugin: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git', + pluginRef: 'plugins.insomnia', + repo: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin', + platforms: ['Android', 'iOS', 'Windows Phone 8'] +}) +export class Insomnia { + + /** + * Keeps awake the application + * @returns {Promise} + */ + @Cordova() + static keepAwake(): Promise { return; } + + /** + * Allows the application to sleep again + * @returns {Promise} + */ + @Cordova() + static allowSleepAgain(): Promise { return; } +}