@capacitor/background-runner 1.0.6-dev-20240416T225651.0 → 1.0.6-dev-20240423T153554.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,6 +69,23 @@ Read about [Configuring `Info.plist`](https://capacitorjs.com/docs/ios/configura
69
69
 
70
70
  ## Android
71
71
 
72
+ Insert the following line to `android/app/build.gradle`:
73
+
74
+ ```diff
75
+ ...
76
+
77
+ repositories {
78
+ flatDir{
79
+ dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
80
+ + dirs '../../node_modules/@capacitor/background-runner/android/src/main/libs', 'libs'
81
+ }
82
+ }
83
+ ...
84
+
85
+ ```
86
+
87
+ If you are upgrading from 1.0.5 with an existing Android project, be sure to delete the `android-js-engine-release.aar` from `android/src/main/libs`.
88
+
72
89
  ### Geolocation
73
90
 
74
91
  This API requires the following permissions be added to your `AndroidManifest.xml`:
@@ -151,6 +168,8 @@ addEventListener('remoteNotification', (resolve, reject, args) => {
151
168
 
152
169
  Calling `resolve()` \ `reject()` is **required** within every event handler called by the runner. Failure to do this could result in your runner being killed by the OS if your event is called while the app is in the background. If the app is in the foreground, async calls to `dispatchEvent` may not resolve.
153
170
 
171
+ For more real world examples of using Background Runner, check out the [Background Runner Test App](https://github.com/ionic-team/background-runner-testapp).
172
+
154
173
  ## Configuring Background Runner
155
174
 
156
175
  <docgen-config>
@@ -256,6 +275,7 @@ It’s not possible to run persistent, always running background services on mob
256
275
 
257
276
  - Each invocation of your task has approximately up to 30 seconds of runtime before you must call `completed()` or your task is killed.
258
277
  - While you can set an interval to define when your task runs after the app is backgrounded, or how often it should run, this is not guaranteed. iOS will determine when and how often you task will ultimately run, determined in part by how often you app is used.
278
+ - Background tasks are not executed in the simulator.
259
279
 
260
280
  ### Android
261
281
 
@@ -11,8 +11,7 @@ public class BackgroundRunner {
11
11
 
12
12
  public init() {
13
13
  do {
14
- config = try self.loadRunnerConfig()
15
- runner.start()
14
+ config = try self.loadRunnerConfig()
16
15
  } catch {
17
16
  print("could not initialize BackgroundRunner: \(error)")
18
17
  }
@@ -15,36 +15,4 @@ public class Runner {
15
15
  func createContext(name: String) throws -> Context {
16
16
  return try Context(vm: machine, contextName: name, runLoop: runLoop)
17
17
  }
18
-
19
- func start() {
20
- thread = Thread { [weak self] in
21
- defer {
22
- Thread.exit()
23
- }
24
-
25
- guard let self = self else { return }
26
- guard let thread = self.thread else { return }
27
-
28
- while !thread.isCancelled {
29
- self.runLoop.run(mode: .default, before: .distantFuture)
30
- }
31
- }
32
-
33
- thread?.qualityOfService = .userInitiated
34
- thread?.start()
35
- }
36
-
37
- func stop() {
38
- guard let thread = self.thread else {
39
- return
40
- }
41
-
42
- thread.cancel()
43
-
44
- while !thread.isFinished {
45
- Thread.sleep(forTimeInterval: 0.05)
46
- }
47
-
48
- self.thread = nil
49
- }
50
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/background-runner",
3
- "version": "1.0.6-dev-20240416T225651.0",
3
+ "version": "1.0.6-dev-20240423T153554.0",
4
4
  "description": "Capacitor Background Runner",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -81,5 +81,5 @@
81
81
  "src": "android"
82
82
  }
83
83
  },
84
- "gitHead": "e1b54f7215adfbfa3f1a173eaf3e077be6d54a02"
84
+ "gitHead": "bfab85e50f1a4708e9100053ade7a7a0357c1654"
85
85
  }