@transistorsoft/capacitor-background-geolocation 8.0.1 → 9.0.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/Package.swift +10 -16
- package/README.md +99 -211
- package/TransistorsoftCapacitorBackgroundGeolocation.podspec +7 -5
- package/android/build.gradle +16 -54
- package/android/src/main/java/com/transistorsoft/bggeo/capacitor/BackgroundGeolocationPlugin.java +132 -70
- package/dist/index.js +198 -189
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs.js +255 -205
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1141 -1092
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.swift +353 -306
- package/package.json +11 -12
- package/src/index.d.ts +10 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +0 -13
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/maven-metadata.xml +0 -13
- package/dist/Events.js +0 -19
- package/dist/Events.js.map +0 -1
- package/dist/declarations/BackgroundGeolocation.d.ts +0 -1632
- package/dist/declarations/interfaces/Authorization.d.ts +0 -185
- package/dist/declarations/interfaces/AuthorizationEvent.d.ts +0 -34
- package/dist/declarations/interfaces/Config.d.ts +0 -2474
- package/dist/declarations/interfaces/ConnectivityChangeEvent.d.ts +0 -18
- package/dist/declarations/interfaces/CurrentPositionRequest.d.ts +0 -45
- package/dist/declarations/interfaces/DeviceInfo.d.ts +0 -33
- package/dist/declarations/interfaces/DeviceSettings.d.ts +0 -223
- package/dist/declarations/interfaces/Geofence.d.ts +0 -319
- package/dist/declarations/interfaces/GeofenceEvent.d.ts +0 -35
- package/dist/declarations/interfaces/GeofencesChangeEvent.d.ts +0 -22
- package/dist/declarations/interfaces/HeartbeatEvent.d.ts +0 -20
- package/dist/declarations/interfaces/HttpEvent.d.ts +0 -313
- package/dist/declarations/interfaces/Location.d.ts +0 -257
- package/dist/declarations/interfaces/LocationAuthorizationAlert.d.ts +0 -41
- package/dist/declarations/interfaces/Logger.d.ts +0 -359
- package/dist/declarations/interfaces/MotionActivityEvent.d.ts +0 -34
- package/dist/declarations/interfaces/MotionChangeEvent.d.ts +0 -15
- package/dist/declarations/interfaces/Notification.d.ts +0 -491
- package/dist/declarations/interfaces/PermissionRationale.d.ts +0 -31
- package/dist/declarations/interfaces/ProviderChangeEvent.d.ts +0 -74
- package/dist/declarations/interfaces/SQLQuery.d.ts +0 -60
- package/dist/declarations/interfaces/Sensors.d.ts +0 -31
- package/dist/declarations/interfaces/State.d.ts +0 -51
- package/dist/declarations/interfaces/Subscription.d.ts +0 -104
- package/dist/declarations/interfaces/TransistorAuthorizationToken.d.ts +0 -63
- package/dist/declarations/interfaces/WatchPositionRequest.d.ts +0 -45
- package/dist/declarations/types.d.ts +0 -188
- package/dist/index.d.ts +0 -3
package/Package.swift
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// swift-tools-version: 5.9
|
|
2
|
-
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
|
3
|
-
// "@transistorsoft/capacitor-background-fetch": "file:../../capacitor-background-fetch"
|
|
4
|
-
|
|
5
2
|
import PackageDescription
|
|
6
3
|
|
|
7
4
|
let package = Package(
|
|
8
5
|
name: "TransistorsoftCapacitorBackgroundGeolocation",
|
|
9
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS(.v14)],
|
|
10
7
|
products: [
|
|
11
8
|
.library(
|
|
12
9
|
name: "TransistorsoftCapacitorBackgroundGeolocation",
|
|
@@ -14,8 +11,10 @@ let package = Package(
|
|
|
14
11
|
)
|
|
15
12
|
],
|
|
16
13
|
dependencies: [
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
|
15
|
+
.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git", from: "3.8.5"),
|
|
16
|
+
.package(url: "https://github.com/transistorsoft/native-background-geolocation.git", from: "4.0.10"),
|
|
17
|
+
.package(url: "https://github.com/transistorsoft/transistor-background-fetch.git", from: "4.0.5")
|
|
19
18
|
],
|
|
20
19
|
targets: [
|
|
21
20
|
.target(
|
|
@@ -23,8 +22,9 @@ let package = Package(
|
|
|
23
22
|
dependencies: [
|
|
24
23
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
|
25
24
|
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
|
26
|
-
"
|
|
27
|
-
"
|
|
25
|
+
.product(name: "TSLocationManager", package: "native-background-geolocation"),
|
|
26
|
+
.product(name: "TSBackgroundFetch", package: "transistor-background-fetch"),
|
|
27
|
+
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack")
|
|
28
28
|
],
|
|
29
29
|
path: "ios/Sources/BackgroundGeolocationPlugin",
|
|
30
30
|
resources: [
|
|
@@ -32,14 +32,8 @@ let package = Package(
|
|
|
32
32
|
],
|
|
33
33
|
linkerSettings: [
|
|
34
34
|
.linkedLibrary("z"),
|
|
35
|
-
.linkedLibrary("sqlite3")
|
|
36
|
-
.linkedLibrary("stdc++")
|
|
35
|
+
.linkedLibrary("sqlite3")
|
|
37
36
|
]
|
|
38
|
-
),
|
|
39
|
-
.binaryTarget(
|
|
40
|
-
name: "TSLocationManager",
|
|
41
|
-
path: "ios/Frameworks/TSLocationManager.xcframework"
|
|
42
37
|
)
|
|
43
38
|
]
|
|
44
|
-
)
|
|
45
|
-
|
|
39
|
+
)
|
package/README.md
CHANGED
|
@@ -7,19 +7,17 @@ Background Geolocation for Capacitor · [ is to use **motion-detection** APIs (
|
|
10
|
+
The plugin's [Philosophy of Operation](../../wiki/Philosophy-of-Operation) is to use **motion-detection** APIs (accelerometer, gyroscope and magnetometer) to detect when the device is *moving* and *stationary*.
|
|
11
11
|
|
|
12
|
-
- When the device is detected to be **moving**, the plugin
|
|
12
|
+
- When the device is detected to be **moving**, the plugin automatically starts recording locations according to the configured `distanceFilter` (metres).
|
|
13
13
|
|
|
14
|
-
- When the device is detected be **stationary**, the plugin
|
|
14
|
+
- When the device is detected to be **stationary**, the plugin automatically turns off location-services to conserve energy.
|
|
15
15
|
|
|
16
|
-
Also available for [Flutter](https://github.com/transistorsoft/flutter_background_geolocation), [Cordova](https://github.com/transistorsoft/cordova-background-geolocation-lt), and [React Native](https://github.com/transistorsoft/
|
|
16
|
+
Also available for [Flutter](https://github.com/transistorsoft/flutter_background_geolocation), [Cordova](https://github.com/transistorsoft/cordova-background-geolocation-lt), and [React Native](https://github.com/transistorsoft/react-native-background-geolocation).
|
|
17
17
|
|
|
18
18
|
----------------------------------------------------------------------------
|
|
19
19
|
|
|
20
|
-
The **[Android module](http://www.transistorsoft.com/shop/products/capacitor-background-geolocation)** requires [purchasing a license](http://www.transistorsoft.com/shop/products/capacitor-background-geolocation).
|
|
21
|
-
|
|
22
|
-
(2018) This plugin is supported **full-time** and field-tested **daily** since 2013.
|
|
20
|
+
The **[Android module](http://www.transistorsoft.com/shop/products/capacitor-background-geolocation)** requires [purchasing a license](http://www.transistorsoft.com/shop/products/capacitor-background-geolocation). However, it *will* work for **DEBUG** builds — try before you buy.
|
|
23
21
|
|
|
24
22
|
----------------------------------------------------------------------------
|
|
25
23
|
|
|
@@ -28,42 +26,54 @@ The **[Android module](http://www.transistorsoft.com/shop/products/capacitor-bac
|
|
|
28
26
|

|
|
29
27
|

|
|
30
28
|
|
|
31
|
-
>
|
|
32
|
-
>
|
|
33
|
-
> For Capacitor 4, use the 4.x version of the plugin.
|
|
29
|
+
> [!IMPORTANT]
|
|
30
|
+
> This plugin requires **Capacitor 5** or higher. For Capacitor 4, use the `4.x` version of the plugin.
|
|
34
31
|
|
|
35
32
|
# Contents
|
|
36
33
|
- ### 😫 [Help!](../../wiki/Help)
|
|
37
|
-
- ### :books: [API Documentation](https://transistorsoft.github.io/capacitor-background-geolocation)
|
|
34
|
+
- ### :books: [API Documentation](https://transistorsoft.github.io/capacitor-background-geolocation/latest)
|
|
38
35
|
- ### [Installing the Plugin](#large_blue_diamond-installing-the-plugin)
|
|
39
36
|
- ### [Setup Guides](#large_blue_diamond-setup-guides)
|
|
40
37
|
- ### [Configure your License](#large_blue_diamond-configure-your-license)
|
|
41
|
-
- ### [Using the
|
|
38
|
+
- ### [Using the Plugin](#large_blue_diamond-using-the-plugin)
|
|
42
39
|
- ### [Example](#large_blue_diamond-example)
|
|
43
40
|
- ### [Debugging](../../wiki/Debugging)
|
|
44
|
-
- ### [
|
|
41
|
+
- ### [Example Apps](#large_blue_diamond-example-apps)
|
|
45
42
|
- ### [Testing Server](#large_blue_diamond-simple-testing-server)
|
|
46
43
|
- ### [Privacy Policy](help/PRIVACY_POLICY.md)
|
|
47
44
|
|
|
45
|
+
---
|
|
46
|
+
|
|
48
47
|
## :large_blue_diamond: Installing the Plugin
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
> [!CAUTION]
|
|
50
|
+
> This is the new v9 version. For previous version, see [`v8.x`](https://github.com/transistorsoft/capacitor-background-geolocation/tree/8.0.1). __`v8.x`__ license keys do not work with __`v9`__. Login to the customer dashboard to generate a __`v9`__ key. See the [Migration Guide](help/MIGRATION-GUIDE-9.0.0.md) for details.
|
|
51
51
|
|
|
52
52
|
### With `yarn`
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
$ npx cap sync
|
|
55
|
+
yarn add @transistorsoft/capacitor-background-geolocation
|
|
56
|
+
npx cap sync
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
### With `npm`
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install @transistorsoft/capacitor-background-geolocation --save
|
|
63
|
+
npx cap sync
|
|
65
64
|
```
|
|
66
65
|
|
|
66
|
+
### Optional: Background Fetch
|
|
67
|
+
|
|
68
|
+
[`@transistorsoft/capacitor-background-fetch`](https://github.com/transistorsoft/capacitor-background-fetch) is a companion plugin that provides a periodic background callback — up to once every 15 minutes — even while your app is suspended. It is not required by the geolocation plugin but is a useful add-on for keeping data in sync.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
yarn add @transistorsoft/capacitor-background-fetch
|
|
72
|
+
npx cap sync
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
67
77
|
## :large_blue_diamond: Setup Guides
|
|
68
78
|
|
|
69
79
|
### iOS
|
|
@@ -72,28 +82,27 @@ $ npx cap sync
|
|
|
72
82
|
### Android
|
|
73
83
|
- [Required Android Setup](help/INSTALL-ANDROID.md)
|
|
74
84
|
|
|
85
|
+
---
|
|
75
86
|
|
|
76
|
-
## :large_blue_diamond: Configure your
|
|
87
|
+
## :large_blue_diamond: Configure your License
|
|
77
88
|
|
|
78
|
-
|
|
79
|
-
[
|
|
80
|
-

|
|
89
|
+
> [!NOTE]
|
|
90
|
+
> If you have **not** [purchased a license](https://www.transistorsoft.com/shop/products/capacitor-background-geolocation#plans), **skip this step** — the plugin is fully functional in *DEBUG* builds so you can evaluate it first.
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
Your license is a **JWT** issued by the [Customer Dashboard](https://www.transistorsoft.com/shop/customers). It encodes all the features (*entitlements*) your subscription includes — there is only **one key** regardless of which add-ons you have.
|
|
83
93
|
|
|
84
|
-
|
|
85
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
86
|
-
package="com.transistorsoft.backgroundgeolocation.react">
|
|
94
|
+
Add your license key to **`android/app/src/main/AndroidManifest.xml`**:
|
|
87
95
|
|
|
96
|
+
```diff
|
|
97
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
88
98
|
<application
|
|
89
99
|
android:name=".MainApplication"
|
|
90
|
-
android:allowBackup="true"
|
|
91
100
|
android:label="@string/app_name"
|
|
92
101
|
android:icon="@mipmap/ic_launcher"
|
|
93
102
|
android:theme="@style/AppTheme">
|
|
94
103
|
|
|
95
104
|
<!-- capacitor-background-geolocation licence -->
|
|
96
|
-
+
|
|
105
|
+
+ <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENSE_KEY_HERE" />
|
|
97
106
|
.
|
|
98
107
|
.
|
|
99
108
|
.
|
|
@@ -101,42 +110,47 @@ $ npx cap sync
|
|
|
101
110
|
</manifest>
|
|
102
111
|
```
|
|
103
112
|
|
|
104
|
-
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## :large_blue_diamond: Using the Plugin
|
|
105
116
|
|
|
106
117
|
```javascript
|
|
107
118
|
import BackgroundGeolocation from "@transistorsoft/capacitor-background-geolocation";
|
|
108
119
|
```
|
|
109
120
|
|
|
121
|
+
---
|
|
122
|
+
|
|
110
123
|
## :large_blue_diamond: Example
|
|
111
124
|
|
|
112
|
-
There are three main steps to using `BackgroundGeolocation
|
|
125
|
+
There are three main steps to using `BackgroundGeolocation`:
|
|
113
126
|
1. Wire up event-listeners.
|
|
114
127
|
2. `#ready` the plugin.
|
|
115
128
|
3. `#start` the plugin.
|
|
116
129
|
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
> [!WARNING]
|
|
131
|
+
> Do not call any API method that requires location-services (e.g. `#getCurrentPosition`, `#watchPosition`, `#start`) until the `#ready` promise resolves.
|
|
119
132
|
|
|
120
133
|
```javascript
|
|
121
|
-
// NO!
|
|
134
|
+
// NO! .ready() has not yet resolved.
|
|
122
135
|
BackgroundGeolocation.getCurrentPosition(options);
|
|
123
136
|
BackgroundGeolocation.start();
|
|
124
137
|
|
|
125
138
|
BackgroundGeolocation.ready(config).then((state) => {
|
|
126
|
-
// YES
|
|
139
|
+
// YES — .ready() has resolved.
|
|
127
140
|
BackgroundGeolocation.getCurrentPosition(options);
|
|
128
|
-
BackgroundGeolocation.start();
|
|
141
|
+
BackgroundGeolocation.start();
|
|
129
142
|
});
|
|
130
143
|
|
|
131
|
-
// NO!
|
|
144
|
+
// NO! .ready() has not yet resolved.
|
|
132
145
|
BackgroundGeolocation.getCurrentPosition(options);
|
|
133
146
|
BackgroundGeolocation.start();
|
|
134
147
|
```
|
|
148
|
+
|
|
135
149
|
---------------------------------------------------------------------------------------------
|
|
136
150
|
|
|
137
|
-
### Example
|
|
151
|
+
### Example — *React*
|
|
138
152
|
|
|
139
|
-
<img alt="
|
|
153
|
+
<img alt="React" width="50px" src="https://hackr.io/tutorials/react/logo-react.svg?ver=1610114789" />
|
|
140
154
|
|
|
141
155
|
<details>
|
|
142
156
|
<summary>View Source</summary>
|
|
@@ -165,7 +179,7 @@ const HelloWorld: React.FC = () => {
|
|
|
165
179
|
const [enabled, setEnabled] = React.useState(false);
|
|
166
180
|
const [events, setEvents] = React.useState<any[]>([]);
|
|
167
181
|
|
|
168
|
-
const addEvent = (name: string, event:any) => {
|
|
182
|
+
const addEvent = (name: string, event: any) => {
|
|
169
183
|
setEvents(previous => [...previous, {
|
|
170
184
|
name: name,
|
|
171
185
|
json: JSON.stringify(event, null, 2)
|
|
@@ -173,55 +187,54 @@ const HelloWorld: React.FC = () => {
|
|
|
173
187
|
}
|
|
174
188
|
|
|
175
189
|
React.useEffect(() => {
|
|
176
|
-
/// 1.
|
|
177
|
-
const onLocation:Subscription = BackgroundGeolocation.onLocation((location) => {
|
|
190
|
+
/// 1. Subscribe to events.
|
|
191
|
+
const onLocation: Subscription = BackgroundGeolocation.onLocation((location) => {
|
|
178
192
|
addEvent('onLocation', location);
|
|
179
|
-
})
|
|
193
|
+
});
|
|
180
194
|
|
|
181
|
-
const onMotionChange:Subscription = BackgroundGeolocation.onMotionChange((event) => {
|
|
195
|
+
const onMotionChange: Subscription = BackgroundGeolocation.onMotionChange((event) => {
|
|
182
196
|
addEvent('onMotionChange', event);
|
|
183
197
|
});
|
|
184
198
|
|
|
185
|
-
const onActivityChange:Subscription = BackgroundGeolocation.onActivityChange((event) => {
|
|
199
|
+
const onActivityChange: Subscription = BackgroundGeolocation.onActivityChange((event) => {
|
|
186
200
|
addEvent('onActivityChange', event);
|
|
187
|
-
})
|
|
201
|
+
});
|
|
188
202
|
|
|
189
|
-
const onProviderChange:Subscription = BackgroundGeolocation.onProviderChange((event) => {
|
|
203
|
+
const onProviderChange: Subscription = BackgroundGeolocation.onProviderChange((event) => {
|
|
190
204
|
addEvent('onProviderChange', event);
|
|
191
|
-
})
|
|
205
|
+
});
|
|
192
206
|
|
|
193
|
-
/// 2.
|
|
207
|
+
/// 2. Ready the plugin.
|
|
194
208
|
BackgroundGeolocation.ready({
|
|
195
|
-
// Geolocation
|
|
209
|
+
// Geolocation
|
|
196
210
|
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
197
211
|
distanceFilter: 10,
|
|
198
212
|
// Activity Recognition
|
|
199
213
|
stopTimeout: 5,
|
|
200
|
-
// Application
|
|
201
|
-
debug: true,
|
|
214
|
+
// Application
|
|
215
|
+
debug: true, // <-- enable to hear life-cycle sounds
|
|
202
216
|
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
|
|
203
|
-
stopOnTerminate: false, // <--
|
|
204
|
-
startOnBoot: true, // <--
|
|
217
|
+
stopOnTerminate: false, // <-- continue tracking after the app is closed
|
|
218
|
+
startOnBoot: true, // <-- start tracking when the device boots
|
|
205
219
|
}).then((state) => {
|
|
206
220
|
setReady(true);
|
|
207
|
-
setEnabled(state.enabled)
|
|
221
|
+
setEnabled(state.enabled);
|
|
208
222
|
addEvent('State', state);
|
|
209
223
|
});
|
|
210
224
|
|
|
211
225
|
return () => {
|
|
212
|
-
// Remove
|
|
213
|
-
//
|
|
214
|
-
// each refresh during live-reload.
|
|
226
|
+
// Remove subscriptions when the component unmounts (important during
|
|
227
|
+
// live-reload in development to prevent listener accumulation).
|
|
215
228
|
onLocation.remove();
|
|
216
229
|
onMotionChange.remove();
|
|
217
230
|
onActivityChange.remove();
|
|
218
231
|
onProviderChange.remove();
|
|
219
|
-
}
|
|
232
|
+
};
|
|
220
233
|
}, []);
|
|
221
234
|
|
|
222
|
-
/// 3.
|
|
235
|
+
/// 3. Start / stop BackgroundGeolocation.
|
|
223
236
|
React.useEffect(() => {
|
|
224
|
-
if (!ready) { return }
|
|
237
|
+
if (!ready) { return; }
|
|
225
238
|
|
|
226
239
|
if (enabled) {
|
|
227
240
|
BackgroundGeolocation.start();
|
|
@@ -236,24 +249,24 @@ const HelloWorld: React.FC = () => {
|
|
|
236
249
|
<IonHeader>
|
|
237
250
|
<IonToolbar>
|
|
238
251
|
<IonButtons slot="end">
|
|
239
|
-
<IonLabel>Toggle to <code>{
|
|
240
|
-
<IonToggle checked={enabled} onIonChange={e => setEnabled(e.detail.checked)}/>
|
|
252
|
+
<IonLabel>Toggle to <code>{enabled ? 'stop()' : 'start()'}</code> —></IonLabel>
|
|
253
|
+
<IonToggle checked={enabled} onIonChange={e => setEnabled(e.detail.checked)} />
|
|
241
254
|
</IonButtons>
|
|
242
255
|
</IonToolbar>
|
|
243
256
|
</IonHeader>
|
|
244
257
|
<IonContent fullscreen>
|
|
245
|
-
<div style={{padding:10}}>
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
<div style={{ padding: 10 }}>
|
|
259
|
+
{events.slice().reverse().map((event, i) => (
|
|
260
|
+
<div key={i}>
|
|
261
|
+
<p><strong>{event.name}</strong></p>
|
|
262
|
+
<small><pre><code>{event.json}</code></pre></small>
|
|
263
|
+
<IonItemDivider />
|
|
264
|
+
</div>
|
|
265
|
+
))}
|
|
253
266
|
</div>
|
|
254
267
|
</IonContent>
|
|
255
268
|
</IonPage>
|
|
256
|
-
)
|
|
269
|
+
);
|
|
257
270
|
}
|
|
258
271
|
```
|
|
259
272
|
|
|
@@ -261,157 +274,32 @@ const HelloWorld: React.FC = () => {
|
|
|
261
274
|
|
|
262
275
|
---------------------------------------------------------------------------------------------
|
|
263
276
|
|
|
264
|
-
###
|
|
265
|
-
|
|
266
|
-
<img alt="alt_text" width="55px" src="https://dl.dropbox.com/s/w4hw88clxqmlis2/angular-logo.svg?dl=1" />
|
|
267
|
-
|
|
268
|
-
<details>
|
|
269
|
-
<summary>View Source</summary>
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
import {
|
|
273
|
-
Component,
|
|
274
|
-
NgZone,
|
|
275
|
-
OnDestroy
|
|
276
|
-
} from '@angular/core'
|
|
277
|
-
|
|
278
|
-
import BackgroundGeolocation, {
|
|
279
|
-
Location,
|
|
280
|
-
Subscription
|
|
281
|
-
} from "@transistorsoft/capacitor-background-geolocation";
|
|
282
|
-
|
|
283
|
-
@Component({
|
|
284
|
-
selector: 'hello-world',
|
|
285
|
-
template: `
|
|
286
|
-
<ion-header>
|
|
287
|
-
<ion-toolbar>
|
|
288
|
-
<ion-buttons slot="end">
|
|
289
|
-
<ion-label>Toggle to <code>{{(enabled ? 'stop()' : 'start()')}}</code> —></ion-label>
|
|
290
|
-
<ion-toggle [(ngModel)]="enabled" (ionChange)="onToggleEnabled()" style="display:block;"></ion-toggle>
|
|
291
|
-
</ion-buttons>
|
|
292
|
-
</ion-toolbar>
|
|
293
|
-
</ion-header>
|
|
294
|
-
<ion-content fullscreen>
|
|
295
|
-
<div *ngFor="let event of events.slice().reverse()" style="padding:10px">
|
|
296
|
-
<div>
|
|
297
|
-
<p><strong>{{event.name}}</strong></p>
|
|
298
|
-
<small><pre><code>{{event.json}}</code></pre></small>
|
|
299
|
-
<ion-item-divider></ion-item-divider>
|
|
300
|
-
</div>
|
|
301
|
-
</div>
|
|
302
|
-
</ion-content>
|
|
303
|
-
`,
|
|
304
|
-
styles: []
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
export class HelloWorldPage implements OnDestroy {
|
|
308
|
-
ready:boolean = false;
|
|
309
|
-
enabled:boolean = false;
|
|
310
|
-
events:any = [];
|
|
311
|
-
subscriptions:Subscription[] = [];
|
|
312
|
-
|
|
313
|
-
constructor(private zone:NgZone) {}
|
|
314
|
-
|
|
315
|
-
/// WARNING: DO NOT Use ionViewWillEnter to configure the SDK -- use ngAfterContentInit.
|
|
316
|
-
/// ionViewWillEnter only executes when the app is brought to the foreground.
|
|
317
|
-
/// It will NOT execute when the app is launched in the background, as the SDK will often do.
|
|
318
|
-
///
|
|
319
|
-
ngAfterContentInit() {
|
|
320
|
-
/// Step 1: Subscribe to BackgroundGeolocation events.
|
|
321
|
-
this.subscriptions.push(BackgroundGeolocation.onLocation((location) => {
|
|
322
|
-
this.addEvent('onLocation', location);
|
|
323
|
-
}))
|
|
324
|
-
|
|
325
|
-
this.subscriptions.push(BackgroundGeolocation.onMotionChange((event) => {
|
|
326
|
-
this.addEvent('onMotionChange', event);
|
|
327
|
-
}))
|
|
328
|
-
|
|
329
|
-
this.subscriptions.push(BackgroundGeolocation.onActivityChange((event) => {
|
|
330
|
-
this.addEvent('onActivityChange', event);
|
|
331
|
-
}))
|
|
332
|
-
|
|
333
|
-
this.subscriptions.push(BackgroundGeolocation.onProviderChange((event) => {
|
|
334
|
-
this.addEvent('onProviderChange', event);
|
|
335
|
-
}))
|
|
336
|
-
|
|
337
|
-
/// Step 2: Ready the plugin.
|
|
338
|
-
BackgroundGeolocation.ready({
|
|
339
|
-
// Geolocation Config
|
|
340
|
-
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
341
|
-
distanceFilter: 10,
|
|
342
|
-
// Activity Recognition
|
|
343
|
-
stopTimeout: 5,
|
|
344
|
-
// Application config
|
|
345
|
-
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
|
|
346
|
-
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
|
|
347
|
-
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
|
|
348
|
-
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
|
|
349
|
-
}).then((state) => {
|
|
350
|
-
// BackgroundGeolocation is now ready to use.
|
|
351
|
-
this.ready = true;
|
|
352
|
-
this.enabled = state.enabled;
|
|
353
|
-
this.addEvent('State', state);
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/// When view is destroyed, be sure to .remove() all BackgroundGeolocation
|
|
358
|
-
/// event-subscriptions.
|
|
359
|
-
ngOnDestroy() {
|
|
360
|
-
this.subscriptions.forEach((subscription:Subscription) => {
|
|
361
|
-
subscription.remove();
|
|
362
|
-
})
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/// Add an event to the view.
|
|
366
|
-
addEvent(name:string, event:any) {
|
|
367
|
-
this.zone.run(() => {
|
|
368
|
-
this.events.push({
|
|
369
|
-
name: name,
|
|
370
|
-
json: JSON.stringify(event, null, 2)
|
|
371
|
-
})
|
|
372
|
-
})
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/// Toggle the plugin on/off.
|
|
376
|
-
onToggleEnabled() {
|
|
377
|
-
if (!this.ready) { return }
|
|
378
|
-
|
|
379
|
-
this.events = [];
|
|
380
|
-
if (this.enabled) {
|
|
381
|
-
BackgroundGeolocation.start().then((state) => {
|
|
382
|
-
this.addEvent('State', state);
|
|
383
|
-
})
|
|
384
|
-
} else {
|
|
385
|
-
BackgroundGeolocation.stop().then((state) => {
|
|
386
|
-
this.addEvent('State', state);
|
|
387
|
-
})
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
```
|
|
277
|
+
### Promise API
|
|
392
278
|
|
|
393
|
-
|
|
279
|
+
The `BackgroundGeolocation` API supports [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for nearly every method. The exceptions are **`#watchPosition`** and the event-listener methods (`onLocation`, `onProviderChange`, etc.). See the [API Documentation](https://transistorsoft.github.io/capacitor-background-geolocation/latest) for full details.
|
|
394
280
|
|
|
395
|
-
|
|
281
|
+
---
|
|
396
282
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
The `BackgroundGeolocation` Javascript API supports [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) for *nearly* every method (the exceptions are **`#watchPosition`** and adding event-listeners via **`onXXX`** methods (eg: `onLocation`, `onProviderChange`). For more information, see the [API Documentation](https://transistorsoft.github.io/capacitor-background-geolocation)
|
|
283
|
+
## :large_blue_diamond: Example Apps
|
|
400
284
|
|
|
285
|
+
Two example apps are included in the [`example/`](./example) directory:
|
|
401
286
|
|
|
402
|
-
|
|
287
|
+
| App | Description |
|
|
288
|
+
|-----|-------------|
|
|
289
|
+
| [`example/basic`](./example/basic) | Minimal getting-started app — configure, toggle tracking, view events. Start here. |
|
|
290
|
+
| [`example/advanced`](./example/advanced) | Full-featured reference app with live map, geofence tools, all settings, and Transistor server integration. |
|
|
403
291
|
|
|
404
|
-
|
|
292
|
+
See the [example README](./example/README.md) for setup instructions.
|
|
405
293
|
|
|
406
294
|

|
|
407
295
|

|
|
408
296
|
|
|
297
|
+
---
|
|
409
298
|
|
|
410
299
|
## :large_blue_diamond: [Simple Testing Server](https://github.com/transistorsoft/background-geolocation-console)
|
|
411
300
|
|
|
412
|
-
A simple Node-based [web
|
|
301
|
+
A simple Node-based [web application](https://github.com/transistorsoft/background-geolocation-console) with a SQLite database is available for field-testing and performance analysis. If you're familiar with Node you can have it running in about **one minute**.
|
|
413
302
|
|
|
414
303
|

|
|
415
304
|
|
|
416
305
|

|
|
417
|
-
|
|
@@ -13,10 +13,12 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Sources/BackgroundGeolocationPlugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'CocoaLumberjack', '~> 3.
|
|
17
|
-
s.
|
|
18
|
-
s.
|
|
19
|
-
s.resource_bundles = {
|
|
16
|
+
s.dependency 'CocoaLumberjack', '~> 3.8.5'
|
|
17
|
+
s.dependency 'TSLocationManager', '~> 4.0.10'
|
|
18
|
+
s.libraries = 'sqlite3', 'z', 'stdc++'
|
|
19
|
+
s.resource_bundles = {
|
|
20
|
+
'TSLocationManagerPrivacy' => ['ios/Sources/BackgroundGeolocationPlugin/PrivacyInfo.xcprivacy']
|
|
21
|
+
}
|
|
20
22
|
s.static_framework = true
|
|
21
23
|
s.swift_version = '5.1'
|
|
22
|
-
end
|
|
24
|
+
end
|
package/android/build.gradle
CHANGED
|
@@ -26,23 +26,13 @@ rootProject.allprojects {
|
|
|
26
26
|
apply plugin: 'com.android.library'
|
|
27
27
|
|
|
28
28
|
// Android dependencies
|
|
29
|
-
def DEFAULT_COMPILE_SDK_VERSION =
|
|
30
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
31
|
-
def DEFAULT_APP_COMPAT_VERSION = "1.6.1"
|
|
29
|
+
def DEFAULT_COMPILE_SDK_VERSION = 35
|
|
30
|
+
def DEFAULT_TARGET_SDK_VERSION = 35
|
|
32
31
|
|
|
33
32
|
// Plugin dependencies
|
|
34
|
-
def DEFAULT_PLAY_SERVICES_LOCATION_VERSION = "
|
|
35
|
-
def
|
|
36
|
-
def DEFAULT_OK_HTTP_VERSION = "3.12.13"
|
|
37
|
-
def DEFAULT_ANDROID_PERMISSIONS_VERSION = "2.1.6"
|
|
33
|
+
def DEFAULT_PLAY_SERVICES_LOCATION_VERSION = "21.3.0"
|
|
34
|
+
def DEFAULT_TSLOCATIONMANAGER_VERSION = "4.0.+"
|
|
38
35
|
def DEFAULT_EVENTBUS_VERSION = "3.3.1"
|
|
39
|
-
def DEFAULT_LOCAL_BROADCAST_MANAGER_VERSION = "1.0.0"
|
|
40
|
-
def DEFAULT_LIFE_CYCLE_RUNTIME_VERSION = "2.4.1"
|
|
41
|
-
def DEFAULT_LIFE_CYCLE_EXTENSIONS_VERSION = "2.2.0"
|
|
42
|
-
def DEFAULT_LOGBACK_VERSION = "3.0.0"
|
|
43
|
-
def DEFAULT_SLF4J_VERSION = "2.0.7"
|
|
44
|
-
def DEFAULT_WORK_VERSION = "2.8.1"
|
|
45
|
-
def DEFAULT_CONCURRENT_FUTURES_VERSION = "1.1.0"
|
|
46
36
|
|
|
47
37
|
def safeExtGet(prop, fallback) {
|
|
48
38
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
@@ -56,7 +46,7 @@ android {
|
|
|
56
46
|
|
|
57
47
|
compileSdk safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
58
48
|
defaultConfig {
|
|
59
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
49
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
|
|
60
50
|
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
|
|
61
51
|
versionCode 1
|
|
62
52
|
versionName "1.0"
|
|
@@ -85,52 +75,24 @@ repositories {
|
|
|
85
75
|
|
|
86
76
|
|
|
87
77
|
dependencies {
|
|
88
|
-
def
|
|
89
|
-
def
|
|
90
|
-
def hmsLocationVersion = safeExtGet('hmsLocationVersion', DEFAULT_HMS_LOCATION_VERSION);
|
|
91
|
-
def okHttpVersion = safeExtGet('okHttpVersion', DEFAULT_OK_HTTP_VERSION)
|
|
92
|
-
def androidPermissionsVersion = safeExtGet('androidPermissionsVersion', DEFAULT_ANDROID_PERMISSIONS_VERSION)
|
|
78
|
+
def playServicesLocationVersion = safeExtGet('playServicesLocationVersion', DEFAULT_PLAY_SERVICES_LOCATION_VERSION)
|
|
79
|
+
def tslocationmanagerVersion = safeExtGet('tslocationmanagerVersion', DEFAULT_TSLOCATIONMANAGER_VERSION)
|
|
93
80
|
def eventBusVersion = safeExtGet('eventBusVersion', DEFAULT_EVENTBUS_VERSION)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def lifeCycleRuntimeVersion = safeExtGet('lifeCycleRuntimeVersion', DEFAULT_LIFE_CYCLE_RUNTIME_VERSION)
|
|
97
|
-
def lifeCycleExtensionsVersion = safeExtGet('lifeCycleExtensionsVersion', DEFAULT_LIFE_CYCLE_EXTENSIONS_VERSION)
|
|
98
|
-
def logbackVersion = safeExtGet('logbackVersion', DEFAULT_LOGBACK_VERSION);
|
|
99
|
-
def slf4jVersion = safeExtGet('slf4jVersion', DEFAULT_SLF4J_VERSION);
|
|
100
|
-
|
|
81
|
+
|
|
101
82
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
102
83
|
implementation project(':capacitor-android')
|
|
103
|
-
|
|
84
|
+
|
|
104
85
|
testImplementation "junit:junit:$junitVersion"
|
|
105
86
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
106
87
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
107
88
|
|
|
89
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
90
|
+
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
|
|
108
91
|
def locationMajorVersion = playServicesLocationVersion.split('\\.')[0] as int
|
|
109
92
|
if (locationMajorVersion >= 21) {
|
|
110
|
-
api
|
|
111
|
-
} else {
|
|
112
|
-
api
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
implementation "androidx.localbroadcastmanager:localbroadcastmanager:$localBroadcastManagerVersion"
|
|
116
|
-
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
|
|
117
|
-
|
|
118
|
-
api "org.greenrobot:eventbus:$eventBusVersion"
|
|
119
|
-
api "com.squareup.okhttp3:okhttp:$okHttpVersion"
|
|
120
|
-
|
|
121
|
-
// logback-android
|
|
122
|
-
implementation "com.github.tony19:logback-android:$logbackVersion"
|
|
123
|
-
implementation "org.slf4j:slf4j-api:$slf4jVersion"
|
|
124
|
-
|
|
125
|
-
implementation "io.github.nishkarsh:android-permissions:$androidPermissionsVersion"
|
|
126
|
-
// LifeCycleObserver
|
|
127
|
-
implementation "androidx.lifecycle:lifecycle-runtime:$lifeCycleRuntimeVersion"
|
|
128
|
-
implementation "androidx.lifecycle:lifecycle-extensions:$lifeCycleExtensionsVersion"
|
|
129
|
-
|
|
130
|
-
// WorkManager
|
|
131
|
-
def workVersion = safeExtGet('workVersion', DEFAULT_WORK_VERSION)
|
|
132
|
-
def concurrentFuturesVersion = safeExtGet('concurrentFuturesVersion', DEFAULT_CONCURRENT_FUTURES_VERSION)
|
|
133
|
-
implementation "androidx.work:work-runtime:$workVersion"
|
|
134
|
-
implementation "androidx.concurrent:concurrent-futures:$concurrentFuturesVersion"
|
|
135
|
-
|
|
93
|
+
api "com.transistorsoft:tslocationmanager:$tslocationmanagerVersion"
|
|
94
|
+
} else {
|
|
95
|
+
api "com.transistorsoft:tslocationmanager-gms20:$tslocationmanagerVersion"
|
|
96
|
+
}
|
|
97
|
+
api "org.greenrobot:eventbus:$eventBusVersion"
|
|
136
98
|
}
|