Power Management
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.
Repo: https://github.com/Viras-/cordova-plugin-powermanagement
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-powermanagement-orig $ npm install --save @ionic-native/power-management@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows
- Windows Phone
Usage
import { PowerManagement } from '@ionic-native/power-management';
constructor(private powerManagement: PowerManagement) { }
...
this.powerManagement.acquire()
.then(onSuccess)
.catch(onError);
Instance Members
acquire()
Acquire a wakelock by calling this.
Returns: Promise<any>
dim()
This acquires a partial wakelock, allowing the screen to be dimmed.
Returns: Promise<any>
release()
Release the wakelock. It’s important to do this when you’re finished with the wakelock, to avoid unnecessary battery drain.
Returns: Promise<any>
setReleaseOnPause(set)
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 | Type | Details |
---|---|---|
set |
boolean
|
Returns: Promise<any>