Reputation: 19
IONIC 4 BackgroundMode PlugIn is not disable battery optimisation.
I tested these solutions, but not working:
https://github.com/katzer/cordova-plugin-background-mode/issues/430
I try to set:
this.backgroundMode.on("activate").subscribe(()=>{
this.backgroundMode.disableWebViewOptimizations();
this.backgroundMode.disableBatteryOptimizations(); HERE
console.log("background activate !!!!");
});
But i get:
Property 'disableBatteryOptimizations' does not exist on type 'BackgroundMode'. Did you mean 'disableWebViewOptimizations'
Environment:
Ionic:
ionic (Ionic CLI) : 4.12.0 (C:\Users\Julio\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : @ionic/angular 4.9.1 @angular-devkit/build-angular : 0.801.3 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.0.0
Cordova:
cordova (Cordova CLI) : 9.0.0 ([email protected]) Cordova Platforms : android 8.1.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.1, (and 6 other plugins)
System:
Android SDK Tools : 26.1.1 (C:\Users\Julio\AppData\Local\Android\Sdk) NodeJS : v11.12.0 (C:\Program Files\nodejs\node.exe) npm : 6.7.0 OS : Windows 10
Any suggestion?
Upvotes: -1
Views: 1870
Reputation: 5
try this First remove all the platforms, that is ios or android
Now, add the following plugin, ionic cordova plugin add https://github.com/tushe/cordova-plugin-background-mode.git
Then install the latest version of background-mode using npm install --save @ionic-native/background-mode@latest
Add your platforms again then retry.
Upvotes: 0