cordova-plugin-power-optimization
v0.0.4
Published
*Cordova plugin power save* ========================================================= This plugins give you android PowerManager methods with cordova.
Downloads
370
Maintainers
Readme
Cordova plugin power save
This plugins give you android PowerManager methods with cordova.
To use this plugin, be sure that your app is allowed to use this features in this link: https://developer.android.com/training/monitoring-device-state/doze-standby
Android Custom Roms made sometimes your apps unfunctional due to:
- Your App is killed when it's not in foreground
- Notification message do not appear
- Your services is killed by agressive power saving mode
Please if you have a Samsung, Meizu, Letv test this plugin to help me, thanks!
Current protected apps supported devices:
- Huawei (TESTED)
- Xiaomi (TESTED)
- Samsung (NOT TESTED)
- Meizu ( NOT TESTED)
- Letv (NOT TESTED)
Instalation
cordova plugin add cordova-plugin-power-optimization
Usage
Check if the battery optimization is ignoring:
cordova.plugins.PowerOptimization.IsIgnoringBatteryOptimizations().then((result)=> {
console.log(result);
}, (err) => {
console.error(err);
});
Request permisson to ignore optimizations:
cordova.plugins.PowerOptimization.RequestOptimizations().then((result) => {
console.log('ok');
}, (err) => {
console.error(err);
});
Go to battery optimizations configurations menu:
cordova.plugins.PowerOptimization.RequestOptimizationsMenu().then((result) => {
console.log('ok');
}, (err) => {
console.error(err);
});
Check if have any data restrictions in background:
cordova.plugins.PowerOptimization.IsIgnoringDataSaver().then((result) => {
console.log(result);
}, (err) => {
console.error(err);
});
Go to data restrictions in background configurations menu:
cordova.plugins.PowerOptimization.RequestDataSaverMenu().then((result) => {
console.log('ok');
}, (err) => {
console.error(err);
});
Check if have another battery restriction is present into phone (like huawei, xiaomi, etc):
cordova.plugins.PowerOptimization.HaveProtectedAppsCheck().then((result) => {
console.log(result);
}, (err) => {
console.error(err);
});
Go to configurations menu if another battery restriction is present into phone (like huawei, xiaomi, etc). You can send true into params if you want to force show the menu (is only show the fist time without params):
cordova.plugins.PowerOptimization.ProtectedAppCheck().then((result) => {
console.log(result);
}, (err) => {
console.error(err);
});
Notes
Be sure that your AndroidManifest.xml contains this permission
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />