mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-17 00:51:07 +08:00
feat(power-management): add power management support (#489)
This commit is contained in:
parent
00d87dba98
commit
cd82a5393e
@ -72,6 +72,7 @@ import { OneSignal } from './plugins/onesignal';
|
|||||||
import { PhotoViewer } from './plugins/photo-viewer';
|
import { PhotoViewer } from './plugins/photo-viewer';
|
||||||
import { ScreenOrientation } from './plugins/screen-orientation';
|
import { ScreenOrientation } from './plugins/screen-orientation';
|
||||||
import { PinDialog } from './plugins/pin-dialog';
|
import { PinDialog } from './plugins/pin-dialog';
|
||||||
|
import { PowerManagement } from './plugins/power-management';
|
||||||
import { Printer } from './plugins/printer';
|
import { Printer } from './plugins/printer';
|
||||||
import { Push } from './plugins/push';
|
import { Push } from './plugins/push';
|
||||||
import { SafariViewController } from './plugins/safari-view-controller';
|
import { SafariViewController } from './plugins/safari-view-controller';
|
||||||
@ -178,6 +179,7 @@ OneSignal,
|
|||||||
PhotoViewer,
|
PhotoViewer,
|
||||||
ScreenOrientation,
|
ScreenOrientation,
|
||||||
PinDialog,
|
PinDialog,
|
||||||
|
PowerManagement,
|
||||||
Screenshot,
|
Screenshot,
|
||||||
SecureStorage,
|
SecureStorage,
|
||||||
Shake,
|
Shake,
|
||||||
@ -266,6 +268,7 @@ window['IonicNative'] = {
|
|||||||
PhotoViewer: PhotoViewer,
|
PhotoViewer: PhotoViewer,
|
||||||
ScreenOrientation: ScreenOrientation,
|
ScreenOrientation: ScreenOrientation,
|
||||||
PinDialog: PinDialog,
|
PinDialog: PinDialog,
|
||||||
|
PowerManagement: PowerManagement,
|
||||||
SafariViewController: SafariViewController,
|
SafariViewController: SafariViewController,
|
||||||
Screenshot: Screenshot,
|
Screenshot: Screenshot,
|
||||||
SecureStorage: SecureStorage,
|
SecureStorage: SecureStorage,
|
||||||
|
49
src/plugins/power-management.ts
Normal file
49
src/plugins/power-management.ts
Normal file
@ -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; }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user