react-native-background-geolocation 4.3.0 → 4.4.3
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/CHANGELOG.md +42 -0
- package/README.md +209 -61
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.aar → 3.1.35/tslocationmanager-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.pom → 3.1.35/tslocationmanager-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +4 -5
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.aar → 3.1.35/tslocationmanager-reverse-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.pom → 3.1.35/tslocationmanager-reverse-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/maven-metadata.xml +4 -5
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocationModule.java +40 -80
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.m +65 -136
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/Info.plist +9 -9
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeResources +1 -1
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/Info.plist +9 -9
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/TSLocationManager +0 -0
- package/package.json +3 -3
- package/src/NativeModule.js +77 -31
- package/src/declarations/BackgroundGeolocation.d.ts +52 -32
- package/src/declarations/interfaces/Subscription.d.ts +104 -0
- package/src/index.js +16 -16
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.4.3 — 2021-11-10
|
|
4
|
+
* [Fixed][iOS] Backwards compatibility issue: react-native@0.66 does have this method. `No visible @interface for 'RCTEventEmitter' declares the selector 'invalidate' in RNBackgroundGeolocation.m`.
|
|
5
|
+
|
|
6
|
+
## 4.4.2 — 2021-10-29
|
|
7
|
+
* [Fixed][Android] Android 12 behaviour changes mean that foreground-services remain running. When an Android app is terminated, the app process does not terminate (since the foreground-service is active) and `RNBackgroundGeolocationModule` remains in memory. Given that, the plugin cannot rely on registering its event-listeners in the `RNBackgroundGeolocationModule` constructor, but must perform that task when `.ready()` is called. This also requires resetting `mReady = false` when the `MainActivity` is destroyed, so that the next time `.ready()` is called, the event-listeners are re-registered.
|
|
8
|
+
* [Fixed][Android] When `.ready()` is called __`reset: false`__, the `success` callback was not invoked with the current `State`. This bug was introduced in previous `v4.4.1`.
|
|
9
|
+
|
|
10
|
+
## 4.4.1 — 2021-10-29
|
|
11
|
+
* [Added] Added a `Subscription` interface to Typescript API. Added helpful docs to Subscription for new event-handler subscriptions.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import BackgroundGeolocation, {
|
|
15
|
+
Subscription
|
|
16
|
+
} from "...";
|
|
17
|
+
.
|
|
18
|
+
.
|
|
19
|
+
.
|
|
20
|
+
const subscription:Subscription = BacckgroundGeolocation.onLocation(myHandler);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 4.4.0 — 2021-10-25
|
|
24
|
+
* [Added] New `Authorization.strategy "SAS"` (alternative to default `JWT`).
|
|
25
|
+
* [Fixed] Fixed __`RCTEventEmitter`__ warning "addListener", "removeListeners". A corresponding fix has also been released for [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch/blob/master/CHANGELOG.md#404--2021-10-22) so be sure to update to `background-fetch >= 4.0.4`.
|
|
26
|
+
* [Changed] **Deprecated** `BackgroundGeolocation.removeListener`. All event-handlers now return a `react-native` `Subscription` instance containing a `.remove()` method. You will keep track of your own `subscription` instances and call `.remove()` upon them when you wish to remove an event listener. Eg:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
/// OLD
|
|
30
|
+
const onLocation = (location) => {
|
|
31
|
+
console.log('[onLocation');
|
|
32
|
+
}
|
|
33
|
+
BackgroundGeolocation.onLocation(onLocation);
|
|
34
|
+
...
|
|
35
|
+
// deprecated: removeListener
|
|
36
|
+
BackgroundGeolocation.removeListener('location', onLocation);
|
|
37
|
+
|
|
38
|
+
/// NEW: capture returned subscription instance.
|
|
39
|
+
const onLocationSubscription = BackgroundGeolocation.onLocation(onLocation);
|
|
40
|
+
...
|
|
41
|
+
// Removing an event-listener.
|
|
42
|
+
onLocationSubscription.remove();
|
|
43
|
+
```
|
|
44
|
+
|
|
3
45
|
## 4.3.0 — 2021-09-14
|
|
4
46
|
|
|
5
47
|
* [Added][Android] Implement new Android 12 "reduced accuracy" mechanism `requestTemporaryFullAccuracy`.
|
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ The **[Android module](http://www.transistorsoft.com/shop/products/react-native-
|
|
|
29
29
|

|
|
30
30
|
|
|
31
31
|
# Contents
|
|
32
|
+
- ### 😫 [Help!](../../wiki/Help)
|
|
32
33
|
- ### :books: [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation)
|
|
33
34
|
- ### [Installing the Plugin](#large_blue_diamond-installing-the-plugin)
|
|
34
35
|
- ### [Setup Guides](#large_blue_diamond-setup-guides)
|
|
@@ -136,40 +137,77 @@ For more information, see [this blog post](https://medium.com/@transistorsoft/ne
|
|
|
136
137
|
|
|
137
138
|
There are three main steps to using `BackgroundGeolocation`
|
|
138
139
|
1. Wire up event-listeners.
|
|
139
|
-
2.
|
|
140
|
-
3.
|
|
140
|
+
2. `.ready(config)` the plugin.
|
|
141
|
+
3. `.start()` the plugin.
|
|
142
|
+
|
|
143
|
+
:warning: Do not execute *any* API method which will require accessing location-services until the **`.ready(config)`** method resolves (eg: `#getCurrentPosition`, `#watchPosition`, `#start`).
|
|
141
144
|
|
|
142
145
|
```javascript
|
|
143
|
-
//
|
|
144
|
-
|
|
146
|
+
// NO! .ready() has not resolved.
|
|
147
|
+
BackgroundGeolocation.getCurrentPosition(options);
|
|
148
|
+
BackgroundGeolocation.start();
|
|
149
|
+
|
|
150
|
+
BackgroundGeolocation.ready(config).then((state) => {
|
|
151
|
+
// YES -- .ready() has now resolved.
|
|
152
|
+
BackgroundGeolocation.getCurrentPosition(options);
|
|
153
|
+
BackgroundGeolocation.start();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// NO! .ready() has not resolved.
|
|
157
|
+
BackgroundGeolocation.getCurrentPosition(options);
|
|
158
|
+
BackgroundGeolocation.start();
|
|
159
|
+
```
|
|
145
160
|
|
|
146
|
-
export default class App extends Component {
|
|
147
|
-
componentWillMount() {
|
|
148
|
-
////
|
|
149
|
-
// 1. Wire up event-listeners
|
|
150
|
-
//
|
|
151
161
|
|
|
152
|
-
|
|
153
|
-
BackgroundGeolocation.onLocation(this.onLocation, this.onError);
|
|
162
|
+
### Example 1. — React *Functional Component*
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
<details>
|
|
165
|
+
<summary>Show Source</summary>
|
|
157
166
|
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
```javascript
|
|
168
|
+
|
|
169
|
+
import React from 'react';
|
|
170
|
+
import {
|
|
171
|
+
Switch,
|
|
172
|
+
Text,
|
|
173
|
+
View,
|
|
174
|
+
} from 'react-native';
|
|
160
175
|
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
import BackgroundGeolocation, {
|
|
177
|
+
Location,
|
|
178
|
+
Subscription
|
|
179
|
+
} from "react-native-background-geolocation";
|
|
163
180
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
181
|
+
const HelloWorld = () => {
|
|
182
|
+
const [enabled, setEnabled] = React.useState(false);
|
|
183
|
+
const [location, setLocation] = React.useState('');
|
|
184
|
+
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
/// 1. Subscribe to events.
|
|
187
|
+
const onLocation:Subscription = BackgroundGeolocation.onLocation((location) => {
|
|
188
|
+
console.log('[onLocation]', location);
|
|
189
|
+
setLocation(JSON.stringify(location, null, 2));
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
const onMotionChange:Subscription = BackgroundGeolocation.onMotionChange((event) => {
|
|
193
|
+
console.log('[onMotionChange]', event);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const onActivityChange:Subscription = BackgroundGeolocation.onActivityChange((event) => {
|
|
197
|
+
console.log('[onMotionChange]', event);
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
const onProviderChange:Subscription = BackgroundGeolocation.onProviderChange((event) => {
|
|
201
|
+
console.log('[onProviderChange]', event);
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
/// 2. ready the plugin.
|
|
167
205
|
BackgroundGeolocation.ready({
|
|
168
206
|
// Geolocation Config
|
|
169
207
|
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
170
208
|
distanceFilter: 10,
|
|
171
209
|
// Activity Recognition
|
|
172
|
-
stopTimeout:
|
|
210
|
+
stopTimeout: 5,
|
|
173
211
|
// Application config
|
|
174
212
|
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
|
|
175
213
|
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
|
|
@@ -185,68 +223,178 @@ export default class App extends Component {
|
|
|
185
223
|
params: { // <-- Optional HTTP params
|
|
186
224
|
"auth_token": "maybe_your_server_authenticates_via_token_YES?"
|
|
187
225
|
}
|
|
188
|
-
}
|
|
226
|
+
}).then((state) => {
|
|
227
|
+
setEnabled(state.enabled)
|
|
189
228
|
console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
return () => {
|
|
232
|
+
// Remove BackgroundGeolocation event-subscribers when the View is removed or refreshed
|
|
233
|
+
// during development live-reload. Without this, event-listeners will accumulate with
|
|
234
|
+
// each refresh during live-reload.
|
|
235
|
+
onLocation.remove();
|
|
236
|
+
onMotionChange.remove();
|
|
237
|
+
onActivityChange.remove();
|
|
238
|
+
onProviderChange.remove();
|
|
239
|
+
}
|
|
240
|
+
}, []);
|
|
241
|
+
|
|
242
|
+
/// 3. start / stop BackgroundGeolocation
|
|
243
|
+
React.useEffect(() => {
|
|
244
|
+
if (enabled) {
|
|
245
|
+
BackgroundGeolocation.start();
|
|
246
|
+
} else {
|
|
247
|
+
BackgroundGeolocation.stop();
|
|
248
|
+
setLocation('');
|
|
249
|
+
}
|
|
250
|
+
}, [enabled]);
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<View style={{alignItems:'center'}}>
|
|
254
|
+
<Text>Click to enable BackgroundGeolocation</Text>
|
|
255
|
+
<Switch value={enabled} onValueChange={setEnabled} />
|
|
256
|
+
<Text style={{fontFamily:'monospace', fontSize:12}}>{location}</Text>
|
|
257
|
+
</View>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
190
260
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
261
|
+
export default HelloWorld;
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
</details>
|
|
265
|
+
|
|
266
|
+
### Example 2. — React *Class Component*
|
|
267
|
+
|
|
268
|
+
<details>
|
|
269
|
+
<summary>Show Source</summary>
|
|
270
|
+
|
|
271
|
+
```javascript
|
|
272
|
+
import React from 'react';
|
|
273
|
+
import {
|
|
274
|
+
Switch,
|
|
275
|
+
Text,
|
|
276
|
+
View,
|
|
277
|
+
} from 'react-native';
|
|
278
|
+
|
|
279
|
+
import BackgroundGeolocation, {
|
|
280
|
+
Location,
|
|
281
|
+
Subscription
|
|
282
|
+
} from "react-native-background-geolocation";
|
|
283
|
+
|
|
284
|
+
export default class HelloWorld extends React.Component {
|
|
285
|
+
subscriptions:Subscription[] = [];
|
|
286
|
+
state:any = {};
|
|
287
|
+
constructor(props:any) {
|
|
288
|
+
super(props);
|
|
289
|
+
this.state = {
|
|
290
|
+
enabled: false,
|
|
291
|
+
location: ''
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
componentDidMount() {
|
|
296
|
+
/// 1. Subscribe to BackgroundGeolocation events.
|
|
297
|
+
this.subscriptions.push(BackgroundGeolocation.onLocation((location) => {
|
|
298
|
+
console.log('[onLocation]', location);
|
|
299
|
+
this.setState({location: JSON.stringify(location, null, 2)})
|
|
300
|
+
}, (error) => {
|
|
301
|
+
console.log('[onLocation] ERROR:', error);
|
|
302
|
+
}))
|
|
303
|
+
|
|
304
|
+
this.subscriptions.push(BackgroundGeolocation.onMotionChange((event) => {
|
|
305
|
+
console.log('[onMotionChange]', event);
|
|
306
|
+
}))
|
|
307
|
+
|
|
308
|
+
this.subscriptions.push(BackgroundGeolocation.onActivityChange((event) => {
|
|
309
|
+
console.log('[onActivityChange]', event);
|
|
310
|
+
}))
|
|
311
|
+
|
|
312
|
+
this.subscriptions.push(BackgroundGeolocation.onProviderChange((event) => {
|
|
313
|
+
console.log('[onProviderChange]', event);
|
|
314
|
+
}))
|
|
315
|
+
|
|
316
|
+
/// 2. ready the plugin.
|
|
317
|
+
BackgroundGeolocation.ready({
|
|
318
|
+
// Geolocation Config
|
|
319
|
+
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
320
|
+
distanceFilter: 10,
|
|
321
|
+
// Activity Recognition
|
|
322
|
+
stopTimeout: 5,
|
|
323
|
+
// Application config
|
|
324
|
+
debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
|
|
325
|
+
logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
|
|
326
|
+
stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
|
|
327
|
+
startOnBoot: true, // <-- Auto start tracking when device is powered-up.
|
|
328
|
+
// HTTP / SQLite config
|
|
329
|
+
url: 'http://yourserver.com/locations',
|
|
330
|
+
batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
|
|
331
|
+
autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
|
|
332
|
+
headers: { // <-- Optional HTTP headers
|
|
333
|
+
"X-FOO": "bar"
|
|
334
|
+
},
|
|
335
|
+
params: { // <-- Optional HTTP params
|
|
336
|
+
"auth_token": "maybe_your_server_authenticates_via_token_YES?"
|
|
198
337
|
}
|
|
199
|
-
})
|
|
338
|
+
}).then((state) => {
|
|
339
|
+
this.setState({enabled: state.enabled});
|
|
340
|
+
console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
|
|
341
|
+
})
|
|
200
342
|
}
|
|
201
343
|
|
|
202
|
-
|
|
344
|
+
/// When view is destroyed (or refreshed during development live-reload),
|
|
345
|
+
/// remove BackgroundGeolocation event subscriptions.
|
|
203
346
|
componentWillUnmount() {
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
onLocation(location) {
|
|
207
|
-
console.log('[location] -', location);
|
|
208
|
-
}
|
|
209
|
-
onError(error) {
|
|
210
|
-
console.warn('[location] ERROR -', error);
|
|
211
|
-
}
|
|
212
|
-
onActivityChange(event) {
|
|
213
|
-
console.log('[activitychange] -', event); // eg: 'on_foot', 'still', 'in_vehicle'
|
|
347
|
+
this.subscriptions.forEach((subscription) => subscription.remove());
|
|
214
348
|
}
|
|
215
|
-
|
|
216
|
-
|
|
349
|
+
|
|
350
|
+
onToggleEnabled(value:boolean) {
|
|
351
|
+
console.log('[onToggleEnabled]', value);
|
|
352
|
+
this.setState({enabled: value})
|
|
353
|
+
if (value) {
|
|
354
|
+
BackgroundGeolocation.start();
|
|
355
|
+
} else {
|
|
356
|
+
this.setState({location: ''});
|
|
357
|
+
BackgroundGeolocation.stop();
|
|
358
|
+
}
|
|
217
359
|
}
|
|
218
|
-
|
|
219
|
-
|
|
360
|
+
|
|
361
|
+
render() {
|
|
362
|
+
return (
|
|
363
|
+
<View style={{alignItems:'center'}}>
|
|
364
|
+
<Text>Click to enable BackgroundGeolocation</Text>
|
|
365
|
+
<Switch value={this.state.enabled} onValueChange={this.onToggleEnabled.bind(this)} />
|
|
366
|
+
<Text style={{fontFamily:'monospace', fontSize:12}}>{this.state.location}</Text>
|
|
367
|
+
</View>
|
|
368
|
+
)
|
|
220
369
|
}
|
|
221
370
|
}
|
|
222
|
-
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```javascript
|
|
226
|
-
BackgroundGeolocation.ready({
|
|
227
|
-
reset: true, // <-- true to always apply the supplied config
|
|
228
|
-
distanceFilter: 10
|
|
229
|
-
}, (state) => {
|
|
230
|
-
console.log('- BackgroundGeolocation is ready: ', state);
|
|
231
|
-
});
|
|
232
371
|
```
|
|
233
|
-
|
|
234
|
-
:warning: Do not execute *any* API method which will require accessing location-services until the callback to **`#ready`** executes (eg: `#getCurrentPosition`, `#watchPosition`, `#start`).
|
|
372
|
+
</details>
|
|
235
373
|
|
|
236
374
|
### Promise API
|
|
237
375
|
|
|
238
|
-
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 **`#
|
|
376
|
+
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`** method (eg: `onLocation`). For more information, see the [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation-android)
|
|
239
377
|
|
|
240
378
|
```javascript
|
|
241
|
-
// Traditional API still works:
|
|
242
379
|
BackgroundGeolocation.ready({
|
|
243
|
-
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
380
|
+
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
244
381
|
distanceFilter: 50
|
|
245
382
|
}).then(state => {
|
|
246
383
|
console.log('- BackgroundGeolocation is ready: ', state);
|
|
247
384
|
}).catch(error => {
|
|
248
|
-
console.
|
|
385
|
+
console.warn('- BackgroundGeolocation error: ', error);
|
|
249
386
|
});
|
|
387
|
+
|
|
388
|
+
// Or use await in an async function
|
|
389
|
+
try {
|
|
390
|
+
const state = await BackgroundGeolocation.ready({
|
|
391
|
+
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
|
|
392
|
+
distanceFilter: 50
|
|
393
|
+
})
|
|
394
|
+
console.log('- BackgroundGeolocation is ready: ', state);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
console.warn('- BackgroundGeolocation error: ', error);
|
|
397
|
+
}
|
|
250
398
|
```
|
|
251
399
|
|
|
252
400
|
## :large_blue_diamond: [Demo Application](https://github.com/transistorsoft/rn-background-geolocation-demo)
|
|
Binary file
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3a9143ce4479579c135bbf7f1ca80e9c
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c16850b24271032c3ccb10349ba0774069a67819
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e18fc8dd9d37cd2ee00c64e8e1a78ebc0839cf8515cf52463cfdd0761aa580f9
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
566d4327d7b1b9ab3b271dc61d6d661ac1f4c8c89557de1d11c52928a4af5682c702a315e76f2cf46dc882d405fe3c4d6a958c7f0a885a228b3d0b2a735d8305
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.md5
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
007e6f97f3eef0a29312b614881094d5
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha1
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a558cd1eb103134e207932ea7af8c6cf48cc97d7
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f11bf76c75d7d586ceef2978d3bb789deceee30b6c06032edf57647333f98efe
|
package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha512
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d7d2120c48292dc74e273daacad40b19ebfa0617aed7f8fa3b9a8eeb4a10b0ab85e2cc702394f9d1aaf0619b3fdcef728db223c76ffca66288033eb867787acb
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
<groupId>com.transistorsoft</groupId>
|
|
4
4
|
<artifactId>tslocationmanager</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>3.1.
|
|
7
|
-
<release>3.1.
|
|
6
|
+
<latest>3.1.35</latest>
|
|
7
|
+
<release>3.1.35</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>3.1.
|
|
10
|
-
<version>3.1.33</version>
|
|
9
|
+
<version>3.1.35</version>
|
|
11
10
|
</versions>
|
|
12
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20211110133724</lastUpdated>
|
|
13
12
|
</versioning>
|
|
14
13
|
</metadata>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2f0a4b4aca18ec71d130eb7042ba8334
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e7828269f47ca87dd74c5a6952ed1fc464ec074e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1230b611eb4b11c8a65f878e8253cea9f510fac5979f250014c37dc800645054
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
650b7213bc570d2a8697550f5a03ca42657c190a37c490a82fc762d88d6fe5f1170cba23f68530d90180c19ac795c69142b9d39290495a119314163d1ff9577f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
00b43ef20d3f14d733a05d82c4435aaf
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
28d26ba8a4044945fd457d033dbdd457dde4144d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5ee1b9a1bf97d7ea8e005f108f18ec78e2410dfdc45a6e29755a28e5df15daf1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
db1bf3fe2779d75145bcf1929692b5a87e24f9d4046d783a40d903eb7ef0a780f26062c03be017b2a9bb759778b9969eebda9b952abde90ac9e0dd37912d728f
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
<groupId>com.transistorsoft</groupId>
|
|
4
4
|
<artifactId>tslocationmanager-reverse</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>3.1.
|
|
7
|
-
<release>3.1.
|
|
6
|
+
<latest>3.1.35</latest>
|
|
7
|
+
<release>3.1.35</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>3.1.
|
|
10
|
-
<version>3.1.33</version>
|
|
9
|
+
<version>3.1.35</version>
|
|
11
10
|
</versions>
|
|
12
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20211110133724</lastUpdated>
|
|
13
12
|
</versioning>
|
|
14
13
|
</metadata>
|