diff --git a/www/powermanagement.js b/www/powermanagement.js index e9c93fc..7961a7b 100644 --- a/www/powermanagement.js +++ b/www/powermanagement.js @@ -65,9 +65,30 @@ PowerManagement.prototype.dim = function(successCallback,failureCallback) { * @param successCallback function to be called when the device's idle state returns successfully * @param errorCallback function to be called when there was a problem with checking the device's idle state */ - PowerManagement.prototype.isDeviceIdleMode = function(successCallback,failureCallback) { cordova.exec(successCallback, failureCallback, 'PowerManagement', 'isDeviceIdleMode', []); } +/** + * Checks if the app has been added to the battery optimization whitelist (i.e. ignores battery optimization). Android Only. + * *** Requires minimum API level 23 *** + * + * @param successCallback function to be called when the check of the battery optimization whitelist returns successfully + * @param errorCallback function to be called when there was a problem with the check of the battery optimization whitelist + */ +PowerManagement.prototype.isIgnoringBatteryOptimizations = function (successCallback,failureCallback) { + cordova.exec(successCallback, failureCallback, 'PowerManagement', 'isIgnoringBatteryOptimizations', []); +}; + +/** + * Opens a dialog that allows the use to add the app to the battery optimization whitelist. Android Only. + * *** Requires minimum API level 23 *** + * + * @param successCallback function to be called when adding the app to the battery optimization whitelist is successful + * @param errorCallback function to be called when there was a problem with adding the app to the battery optimization whitelist + */ +PowerManagement.prototype.addAppToBatteryWhitelist = function (successCallback,failureCallback) { + cordova.exec(successCallback, failureCallback, 'PowerManagement', 'addAppToBatteryWhitelist', []); +}; + module.exports = new PowerManagement();