@capacitor/background-runner 1.0.6-dev-20240416T212318.0 → 1.0.6-dev-20240418T183044.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
|
@@ -99,7 +99,7 @@ Note that even if the permission is present, users can still disable exact notif
|
|
|
99
99
|
Read about [Setting Permissions](https://capacitorjs.com/docs/android/configuration#setting-permissions) in the [Android Guide](https://capacitorjs.com/docs/android) for more information on setting Android permissions.
|
|
100
100
|
|
|
101
101
|
## About Background Runner
|
|
102
|
-
During the
|
|
102
|
+
During the course of building complex applications, its sometimes necessary to perform work while the application is not in the foreground. The challenge with standard Capacitor applications is that the webview is not available when these background events occur, requiring you to write native code to handle these events. This is where the Background Runner plugin comes in.
|
|
103
103
|
|
|
104
104
|
Background Runner makes it easy to write JavaScript code to handle native background events. All you need to do is create your runner JavaScript file and [define your configuration](#configuring-background-runner), then the Background Runner plugin will automatically configure and schedule a native background task that will be executed according to your config and the rules of the platform. No modification to your UI code is necessary.
|
|
105
105
|
|
|
@@ -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-
|
|
3
|
+
"version": "1.0.6-dev-20240418T183044.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": "
|
|
84
|
+
"gitHead": "11124d27dab552da6e4c3f537607419a702c933d"
|
|
85
85
|
}
|