2 Commits

Author SHA1 Message Date
Nathan Kerr
48a06fc3eb Update event firing.
Closes #5
2019-08-01 13:44:43 -07:00
Nathan Kerr
a3063aed68 Add information about battery optimizations 2019-07-31 18:48:02 +00:00
2 changed files with 9 additions and 1 deletions

View File

@@ -120,6 +120,14 @@ cordova.plugins.backgroundMode.wakeUp();
cordova.plugins.backgroundMode.unlock();
```
### Request to disable battery optimizations
Starting in Android 8, apps can be put to sleep to conserve battery. When this happens (usually after 5 minutes or so), the background task is killed. This will cause things like MQTT connections to break.
This method will show a permission prompt for the user (only if the app hasn't been granted permission) to ignore the optimization.
```js
cordova.plugins.backgroundMode.disableWebViewOptimizations();
```
### Notification
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.

View File

@@ -222,7 +222,7 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate";
NSString* flag = [NSString stringWithFormat:@"%@._isActive=%@;",
kAPPBackgroundJsNamespace, active];
NSString* depFn = [NSString stringWithFormat:@"%@.on%@();",
NSString* depFn = [NSString stringWithFormat:@"%@.on('%@');",
kAPPBackgroundJsNamespace, event];
NSString* fn = [NSString stringWithFormat:@"%@.fireEvent('%@');",