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:
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.
backgroundMode.disable : When background mode has been disabled it will pause the app in background mode.
backgroundMode.isEnabled : This method provides the information to the user about background is enabled or disabled. Provides true or false values.
backgroundMode.isActive : This method works when background mode has been activated or not.
backgroundMode.onactive : We can notify the user that background mode has been activated.