Hello Readers,
Cordova background mode plugin keeps the app running in background mode. When app pause in background mode and the system keeps open the network but doesn't send data until app resumes. This plugin helps in those applications which are network communication based or directly interact to the users.
This plugin supports Android, iOS ( iOS8 or more), Wp8 platforms.
First of all we need to install the plugin through CLI:
$ cordova plugin add https://github.com/katzer/cordova-plugin-background-mode.git
This plugin creates cordova.plugins.backgroundMode object and this object has some methods which are as follows:
- backgroundMode.enable : Background mode of app will be activated when app goes to the background mode once and deactivated when it comes to foreground mode. To make this happen we need to call backgroundMode.enable method.
cordova.plugins.backgroundMode.enable();
- backgroundMode.disable : When background mode has been disabled it will pause the app in background mode.
cordova.plugins.backgroundMode.disable();
- backgroundMode.isEnabled : This method provides the information to the user about background is enabled or disabled. Provides true or false values.
cordova.plugins.backgroundMode.isEnabled();
- backgroundMode.isActive : This method works when background mode has been activated or not.
cordova.plugins.backgroundMode.isActive();
- backgroundMode.onactive : We can notify the user that background mode has been activated.
cordova.plugins.backgroundMode.onactivate = function() {};
- backgroundMode.ondeactive : We can notify the user that background mode has been deactivated.
cordova.plugins.backgroundMode.ondeactivate = function() {};
- backgroundMode.onfailure : We can notify the users that background mode could not been activated. This method generates error code which describes the error.
cordova.plugins.backgroundMode.onfailure = function(errorCode) {};
For more details please visit: Click here
Hope this will help you :)
0 Comment(s)