Background Mode is running for only few(probably 5 mins) minutes in Android 8 and Android 9
See original GitHub issueThe App is running for almost 5 minutes at the background. After that, it stops working. If I resume then it starts again.
I have tried several solutions. I have also used the plugin https://github.com/DavidBriglio/cordova-plugin-foreground-service and added
cordova.plugins.foregroundService.start('GPS Running', 'Background Service', 'myicon', 3, 10);
cordova.plugins.backgroundMode.disableBatteryOptimizations();
cordova.plugins.backgroundMode.disableWebViewOptimizations();
But it did not work. I also tried with Cordova power management. This is my GitHub repo https://github.com/ahsanhabib23/testBackgroundIonic3 where the issue has been reproduced.
I am using the fork version. Most added the library by running this command
cordova plugin add https://github.com/katzer/cordova-plugin-background-mode --nofetch
I know there is an existing open issue. But still posting because comments from there did not help.
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.5
@ionic/app-scripts : 3.2.2
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 6 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/bs236/Library/Android/sdk/)
ios-deploy : 1.9.2
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS High Sierra
Xcode : Xcode 10.1 Build version 10B61
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:33
Solução crie uma service com uma notificação passos!!! index.js >> receivedEvent, onDeviceReady
plugin.mxl add permission
<config-file target="AndroidManifest.xml" parent="/manifest"> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> </config-file>inicie o service com uma notificação pegue parte do codigo plugin powemanger e inclua em seu service ele vai trabalha para servir cordova.plugins.backgroundMode para manter ele sempre ativo! abraços!!! testado Android 8 e Android 9 rodando aqui 24hs por dias! vlw
Do you still have the issue if you use this plugin? https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background