mirror of
https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background
synced 2024-11-22 07:14:54 +00:00
Receive if the background mode is enabled
This commit is contained in:
parent
cbed556154
commit
fc6e6cf51d
@ -1,15 +1,16 @@
|
|||||||
## ChangeLog
|
## ChangeLog
|
||||||
#### Version 0.6.1 (not yet released)
|
#### Version 0.6.1 (not yet released)
|
||||||
- [enhancement:] Set default settings through `setDefaults`.
|
- [enhancement:] Set default settings through `setDefaults`.
|
||||||
|
- [enhancement:] New method `isEnabled`
|
||||||
- [bugfix:] Events caused thread collision.
|
- [bugfix:] Events caused thread collision.
|
||||||
|
|
||||||
|
|
||||||
#### Version 0.6.0 (14.12.2014)
|
#### Version 0.6.0 (14.12.2014)
|
||||||
- [feature:] Android support
|
- [feature:] Android support
|
||||||
- [feature:] Get default settings through `getDefaults`.
|
|
||||||
- [feature:] Change Android notification through `configure`.
|
- [feature:] Change Android notification through `configure`.
|
||||||
- [feature:] `onactivate`, `ondeactivate` and `onfailure` callbacks.
|
- [feature:] `onactivate`, `ondeactivate` and `onfailure` callbacks.
|
||||||
- [___change___:] Disabled by default
|
- [___change___:] Disabled by default
|
||||||
|
- [enhancement:] Get default settings through `getDefaults`.
|
||||||
- [enhancement:] iOS does not require user permissions, internet connection and geo location anymore.
|
- [enhancement:] iOS does not require user permissions, internet connection and geo location anymore.
|
||||||
|
|
||||||
#### Version 0.5.0 (13.02.2014)
|
#### Version 0.5.0 (13.02.2014)
|
||||||
|
13
README.md
13
README.md
@ -69,8 +69,9 @@ More informations can be found [here][PGB_plugin].
|
|||||||
|
|
||||||
## ChangeLog
|
## ChangeLog
|
||||||
#### Version 0.6.1 (not yet released)
|
#### Version 0.6.1 (not yet released)
|
||||||
- [feature:] Get default settings through `getDefaults`.
|
- [enhancement:] Set default settings through `setDefaults`.
|
||||||
- [feature:] Set default settings through `setDefaults`.
|
- [enhancement:] New method `isEnabled`
|
||||||
|
- [bugfix:] Events caused thread collision.
|
||||||
|
|
||||||
#### Further informations
|
#### Further informations
|
||||||
- The former `plugin.backgroundMode` namespace has been deprecated and will be removed with the next major release.
|
- The former `plugin.backgroundMode` namespace has been deprecated and will be removed with the next major release.
|
||||||
@ -85,6 +86,7 @@ The plugin creates the object ```cordova.plugins.backgroundMode``` with the fol
|
|||||||
|
|
||||||
1. [backgroundMode.enable][enable]
|
1. [backgroundMode.enable][enable]
|
||||||
2. [backgroundMode.disable][disable]
|
2. [backgroundMode.disable][disable]
|
||||||
|
3. [backgroundMode.isEnabled][is_enabled]
|
||||||
3. [backgroundMode.getDefaults][android_specifics]
|
3. [backgroundMode.getDefaults][android_specifics]
|
||||||
4. [backgroundMode.setDefaults][android_specifics]
|
4. [backgroundMode.setDefaults][android_specifics]
|
||||||
2. [backgroundMode.configure][android_specifics]
|
2. [backgroundMode.configure][android_specifics]
|
||||||
@ -122,6 +124,13 @@ The background mode can be disabled through the `backgroundMode.disable` interfa
|
|||||||
cordova.plugins.backgroundMode.disable();
|
cordova.plugins.backgroundMode.disable();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Receive if the background mode is enabled
|
||||||
|
The `backgroundMode.isActivated` interface can be used to get the information if the background mode is enabled or disabled.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var enabled = cordova.plugins.backgroundMode.isEnabled();
|
||||||
|
```
|
||||||
|
|
||||||
### Get informed when the background mode has been activated
|
### Get informed when the background mode has been activated
|
||||||
The `backgroundMode.onactivate` interface can be used to get notified when the background mode has been activated.
|
The `backgroundMode.onactivate` interface can be used to get notified when the background mode has been activated.
|
||||||
|
|
||||||
|
@ -41,6 +41,13 @@ channel.onCordovaReady.subscribe(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* Flag indicated if the mod is enabled.
|
||||||
|
*/
|
||||||
|
exports._isEnabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
@ -60,6 +67,7 @@ exports._defaults = {
|
|||||||
* for the next time.
|
* for the next time.
|
||||||
*/
|
*/
|
||||||
exports.enable = function () {
|
exports.enable = function () {
|
||||||
|
this._isEnabled = true;
|
||||||
cordova.exec(null, null, 'BackgroundMode', 'enable', []);
|
cordova.exec(null, null, 'BackgroundMode', 'enable', []);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,6 +76,7 @@ exports.enable = function () {
|
|||||||
* will not stay awake while in background.
|
* will not stay awake while in background.
|
||||||
*/
|
*/
|
||||||
exports.disable = function () {
|
exports.disable = function () {
|
||||||
|
this._isEnabled = false;
|
||||||
cordova.exec(null, null, 'BackgroundMode', 'disable', []);
|
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.
|
* Called when the background mode has been activated.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user