Receive if the background mode is enabled

This commit is contained in:
Sebastián Katzer
2014-12-14 13:52:38 +01:00
parent cbed556154
commit fc6e6cf51d
3 changed files with 32 additions and 4 deletions

View File

@@ -41,6 +41,13 @@ channel.onCordovaReady.subscribe(function () {
});
/**
* @private
*
* Flag indicated if the mod is enabled.
*/
exports._isEnabled = true;
/**
* @private
*
@@ -60,6 +67,7 @@ exports._defaults = {
* for the next time.
*/
exports.enable = function () {
this._isEnabled = true;
cordova.exec(null, null, 'BackgroundMode', 'enable', []);
};
@@ -68,6 +76,7 @@ exports.enable = function () {
* will not stay awake while in background.
*/
exports.disable = function () {
this._isEnabled = false;
cordova.exec(null, null, 'BackgroundMode', 'disable', []);
};
@@ -115,6 +124,15 @@ exports.configure = function (options) {
}
};
/**
* If the mode is enabled or not.
*
* @return {Boolean}
*/
exports.isEnabled = function () {
return this._isEnabled;
};
/**
* Called when the background mode has been activated.
*/