-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(power-management): add power management support (#489)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<any> {return; } | ||
|
||
/** | ||
* This acquires a partial wakelock, allowing the screen to be dimmed. | ||
*/ | ||
@Cordova() | ||
static dim(): Promise<any> {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<any> {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<any> {return; } | ||
} |