diff --git a/src/index.ts b/src/index.ts index 951d8b9d5..841b0fca0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -72,6 +72,7 @@ import { OneSignal } from './plugins/onesignal'; import { PhotoViewer } from './plugins/photo-viewer'; import { ScreenOrientation } from './plugins/screen-orientation'; import { PinDialog } from './plugins/pin-dialog'; +import { PowerManagement } from './plugins/power-management'; import { Printer } from './plugins/printer'; import { Push } from './plugins/push'; import { SafariViewController } from './plugins/safari-view-controller'; @@ -178,6 +179,7 @@ OneSignal, PhotoViewer, ScreenOrientation, PinDialog, +PowerManagement, Screenshot, SecureStorage, Shake, @@ -266,6 +268,7 @@ window['IonicNative'] = { PhotoViewer: PhotoViewer, ScreenOrientation: ScreenOrientation, PinDialog: PinDialog, + PowerManagement: PowerManagement, SafariViewController: SafariViewController, Screenshot: Screenshot, SecureStorage: SecureStorage, diff --git a/src/plugins/power-management.ts b/src/plugins/power-management.ts new file mode 100644 index 000000000..860733998 --- /dev/null +++ b/src/plugins/power-management.ts @@ -0,0 +1,49 @@ +import {Plugin, Cordova} from './plugin'; +/** + * @name PowerManagement + * @description + * The PowerManagement plugin offers access to the devices power-management functionality. + * It should be used for applications which keep running for a long time without any user interaction. + * + * @usage + * ``` + * import {PowerManagement} from 'ionic-native'; + * + * PowerManagement.acquire() + * .then(onSuccess) + * .catch(onError); + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-powermanagement-orig', + pluginRef: 'https://github.com/Viras-/cordova-plugin-powermanagement', + repo: 'powerManagement' +}) +export class PowerManagement { + /** + * Acquire a wakelock by calling this. + */ + @Cordova() + static acquire(): Promise {return; } + + /** + * This acquires a partial wakelock, allowing the screen to be dimmed. + */ + @Cordova() + static dim(): Promise {return; } + + /** + * Release the wakelock. It's important to do this when you're finished with the wakelock, to avoid unnecessary battery drain. + */ + @Cordova() + static release(): Promise {return; } + + /** + * By default, the plugin will automatically release a wakelock when your app is paused (e.g. when the screen is turned off, or the user switches to another app). + * It will reacquire the wakelock upon app resume. If you would prefer to disable this behaviour, you can use this function. + * @param set {boolean} + */ + @Cordova() + static setReleaseOnPause(set: boolean): Promise {return; } +}