From 537f7a859f6ae7aacadcc42eb6db28571a20eea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Fri, 8 Feb 2019 18:45:03 +0100 Subject: [PATCH] New "disableBatteryOptimizations" function for Android --- plugin.xml | 1 + src/android/BackgroundExt.java | 29 ++++++++++++++++++++++++++++- src/android/BackgroundMode.java | 4 ++-- src/android/ForegroundService.java | 1 - www/background-mode.js | 15 ++++++++++++++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/plugin.xml b/plugin.xml index 52bd90e..004c203 100644 --- a/plugin.xml +++ b/plugin.xml @@ -75,6 +75,7 @@ + webView.loadUrl("javascript:" + js)); } - } diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index 0544192..4e4aa8f 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -320,5 +320,4 @@ public class ForegroundService extends Service { { return (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } - } diff --git a/www/background-mode.js b/www/background-mode.js index 85f9b50..37e6a18 100644 --- a/www/background-mode.js +++ b/www/background-mode.js @@ -160,7 +160,20 @@ exports.disableWebViewOptimizations = function() { if (this._isAndroid) { - cordova.exec(null, null, 'BackgroundMode', 'optimizations', []); + cordova.exec(null, null, 'BackgroundMode', 'webviewoptimizations', []); + } +}; + +/** + * Disables battery optimazation mode for the app. + * + * @return [ Void ] + */ +exports.disableBatteryOptimizations = function() +{ + if (this._isAndroid) + { + cordova.exec(null, null, 'BackgroundMode', 'batteryoptimizations', []); } };