SAMPLE APP :point_right:
Plugin for the Cordova framework to perform infinite background execution.
Most mobile operating systems are multitasking capable, but most apps dont need to run while in background and not present for the user. Therefore they pause the app in background mode and resume the app before switching to foreground mode. The system keeps all network connections open while in background, but does not deliver the data until the app resumes.
Infinite background tasks are not official supported on most mobile operation systems and thus not compliant with public store vendors. A successful submssion isn't garanteed.
Use the plugin by your own risk!
Execute from the projects root folder:
$ cordova plugin add cordova-plugin-background-mode
Or install a specific version:
$ cordova plugin add de.appplant.cordova.plugin.background-mode@VERSION
Or install the latest head version:
$ cordova plugin add https://github.com/katzer/cordova-plugin-background-mode.git
Or install from local source:
$ cordova plugin add cordova-plugin-background-mode --searchpath <path>
The plugin creates the object
cordova.plugins.backgroundMode and is accessible after the deviceready event has been fired.
The plugin is not enabled by default. Once it has been enabled the mode becomes active if the app moves to background.
To disable the background mode:
Once the plugin has been enabled and the app has entered the background, the background mode becomes active.
cordovapluginsbackgroundMode; // => boolean
A non-active mode means that the app is in foreground.
The plugin fires an event each time its status has been changed. These events are
To remove an event listeners:
Android allows to programmatically move from foreground to background or vice versa.
Override the back button on Android to go to background instead of closing the app.
Exclude the app from the recent task list works on Android 5.0+.
To indicate that the app is executing tasks in background and being paused would disrupt the user, the plug-in has to create a notification while in background - like a download progress bar.
The title, text and icon for that notification can be customized as below. Also, by default the app will come to foreground when tapping on the notification. That can be changed by setting resume to false. On Android 5.0+, the color option will set the background color of the notification circle. Also on Android 5.0+, setting hidden to false will make the notification visible on lockscreen.
To modify the currently displayed notification
Note: All properties are optional - only override the things you need to.
In silent mode the plugin will not display a notification - which is not the default. Be aware that Android recommends adding a notification otherwise the OS may pause the app.
Various APIs like playing media or tracking GPS position in background might not work while in background even the background mode is active. To fix such issues the plugin provides a method to disable most optimizations done by Android/CrossWalk.
Note: Calling the method led to increased resource and power consumption.
git checkout -b my-new-feature)
git commit -am 'Add some feature')
git push origin my-new-feature)
This software is released under the Apache 2.0 License.
Made with 😋 from Leipzig
© 2017 appPlant GmbH