Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

cordova-plugin-power-optimization-2

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-power-optimization-2

*Cordova plugin power save* ========================================================= This plugins give you android PowerManager methods with cordova.

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

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" />

Based in this repo:

AppKillerManager

Help liks:

backgroundable-android

Network access in doze mode

REQUEST_IGNORE_BATTERY_OPTIMIZATIONS how to do it right

Android PowerManager

Keywords

ecosystem:cordova

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts