react-native-background-geolocation 5.0.0-beta.3 → 5.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.
@@ -11,7 +11,7 @@ body:
11
11
  id: terms
12
12
  attributes:
13
13
  label: Required Reading
14
- description: "- I have read the Wikis [Philosophy of Operation](../wiki/Philosophy-of-Operation) and [Debugging](../wiki/Debugging)\n- I am aware of the [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/)\n- I am aware of the [CHANGELOG](../blob/master/CHANGELOG.md)"
14
+ description: "- I have read the Wikis [Philosophy of Operation](./wiki/Philosophy-of-Operation) and [Debugging](./wiki/Debugging)\n- I am aware of the [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/)\n- I am aware of the [CHANGELOG](./blob/master/CHANGELOG.md)"
15
15
  options:
16
16
  - label: Confirmed
17
17
  required: true
@@ -11,7 +11,7 @@ body:
11
11
  id: terms
12
12
  attributes:
13
13
  label: Required Reading
14
- description: "- I have read the Wikis [Philosophy of Operation](../wiki/Philosophy-of-Operation) and [Debugging](../wiki/Debugging)\n- I am aware of the [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/)\n- I am aware of the [CHANGELOG](../blob/master/CHANGELOG.md)"
14
+ description: "- I have read the Wikis [Philosophy of Operation](./wiki/Philosophy-of-Operation) and [Debugging](./wiki/Debugging)\n- I am aware of the [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/)\n- I am aware of the [CHANGELOG](./blob/master/CHANGELOG.md)"
15
15
  options:
16
16
  - label: Confirmed
17
17
  required: true
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  | <img src="https://dl.dropbox.com/s/gxl3sr8znhkrtah/expo-logo.png?dl=1" alt="alt text" width="32" /> | Now with *Expo* support |
2
2
  | --- | --- |
3
3
 
4
+
4
5
  Background Geolocation for React Native &middot; [![npm](https://img.shields.io/npm/dm/react-native-background-geolocation.svg)]() [![npm](https://img.shields.io/npm/v/react-native-background-geolocation.svg)]()
5
6
  ============================================================================
6
7
 
@@ -16,7 +17,7 @@ The plugin's [Philosophy of Operation](../../wiki/Philosophy-of-Operation) is to
16
17
 
17
18
  - When the device is detected be **stationary**, the plugin will automatically turn off location-services to conserve energy.
18
19
 
19
- Also available for [Flutter](https://github.com/transistorsoft/flutter_background_geolocation), [Cordova](https://github.com/transistorsoft/cordova-background-geolocation-lt), [NativeScript](https://github.com/transistorsoft/nativescript-background-geolocation-lt) and pure native apps.
20
+ Also available for [Flutter](https://github.com/transistorsoft/flutter_background_geolocation), [Cordova](https://github.com/transistorsoft/cordova-background-geolocation-lt), [Capacitor](https://github.com/transistorsoft/capacitor-background-geolocation) and pure native apps.
20
21
 
21
22
  > [!NOTE]
22
23
  > The **[Android module](http://www.transistorsoft.com/shop/products/react-native-background-geolocation)** requires [purchasing a license](http://www.transistorsoft.com/shop/products/react-native-background-geolocation). However, it *will* work for **DEBUG** builds. It will **not** work with **RELEASE** builds [without purchasing a license](http://www.transistorsoft.com/shop/products/react-native-background-geolocation). This plugin is supported **full-time** and field-tested **daily** since 2013.
@@ -28,9 +29,12 @@ Also available for [Flutter](https://github.com/transistorsoft/flutter_backgroun
28
29
  ![Home](https://dl.dropboxusercontent.com/s/wa43w1n3xhkjn0i/home-framed-350.png?dl=1)
29
30
  ![Settings](https://dl.dropboxusercontent.com/s/8oad228siog49kt/settings-framed-350.png?dl=1)
30
31
 
32
+ > [!CAUTION]
33
+ > This README references the new __`v5.x`__ branch of the SDK. If you're using __`v4.x`__, you must reference [__`v4.x`__](https://github.com/transistorsoft/react-native-background-geolocation/tree/4.19.4) branch.
34
+
31
35
  # Contents
32
36
  - ### 😫 [Help!](../../wiki/Help)
33
- - ### :books: [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/5.0.0-beta)
37
+ - ### :books: [API Documentation](https://transistorsoft.github.io/react-native-background-geolocation/latest)
34
38
  - ### [Installing the Plugin](#large_blue_diamond-installing-the-plugin)
35
39
  - ### [Setup Guides](#large_blue_diamond-setup-guides)
36
40
  - ### [Configure your License](#large_blue_diamond-configure-your-license)
@@ -43,22 +47,25 @@ Also available for [Flutter](https://github.com/transistorsoft/flutter_backgroun
43
47
 
44
48
  ## :large_blue_diamond: Installing the Plugin
45
49
 
50
+ > [!CAUTION]
51
+ > This is the new v5 version. For previous version, see [`v4.x`](https://github.com/transistorsoft/react-native-background-geolocation/tree/4.19.4). __`v4.x`__ license keys do not work with __`v5`__. Login to the customer dashboard to generate a __`v5`__ key.
52
+
46
53
 
47
54
  ### With *Expo*
48
55
 
49
56
  ```shell
50
- npx expo install react-native-background-geolocation@beta
57
+ npx expo install react-native-background-geolocation
51
58
  ```
52
59
 
53
60
  ### With `yarn`
54
61
 
55
62
  ```bash
56
- yarn add react-native-background-geolocation@beta
63
+ yarn add react-native-background-geolocation
57
64
  ```
58
65
 
59
66
  ### With `npm`
60
67
  ```
61
- $ npm install react-native-background-geolocation@beta --save
68
+ $ npm install react-native-background-geolocation --save
62
69
  ```
63
70
 
64
71
  ## :large_blue_diamond: Setup Guides
@@ -79,7 +86,7 @@ $ npm install react-native-background-geolocation@beta --save
79
86
  [www.transistorsoft.com/shop/customers](http://www.transistorsoft.com/shop/customers)
80
87
  ![](https://gallery.mailchimp.com/e932ea68a1cb31b9ce2608656/images/b2696718-a77e-4f50-96a8-0b61d8019bac.png)
81
88
 
82
- 2. Add your license-key to `android/app/src/main/AndroidManifest.xml`:
89
+ 2. __`[Android]`__ Add your license-key to `android/app/src/main/AndroidManifest.xml`:
83
90
 
84
91
  ```diff
85
92
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -93,7 +100,7 @@ $ npm install react-native-background-geolocation@beta --save
93
100
  android:theme="@style/AppTheme">
94
101
 
95
102
  <!-- react-native-background-geolocation licence -->
96
- + <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENCE_KEY_HERE" />
103
+ + <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_ANDROID_LICENCE_KEY_HERE" />
97
104
  .
98
105
  .
99
106
  .
@@ -101,36 +108,20 @@ $ npm install react-native-background-geolocation@beta --save
101
108
  </manifest>
102
109
  ```
103
110
 
104
- ## :large_blue_diamond: Using the plugin ##
111
+ 3. __`[iOS]`__ Add your license-key to your __`Info.plist`__
105
112
 
106
- ```javascript
107
- import BackgroundGeolocation from "react-native-background-geolocation";
108
- ```
113
+ | Key | Type | Value |
114
+ |-----|-------|-------------|
115
+ | *`TSLocationManagerLicense`* | `String` | ` <PASTE YOUR IOS LICENSE KEY HERE> ` |
109
116
 
110
- ### [Typescript](https://facebook.github.io/react-native/blog/2018/05/07/using-typescript-with-react-native) API:
117
+ __`TSLocationManagerLicense`__. Paste the contents of your license key into the __`value`__.
111
118
 
112
- For those using [Typescript](https://facebook.github.io/react-native/blog/2018/05/07/using-typescript-with-react-native) (__recommended__), you can also `import` the interfaces:
113
- ```javascript
114
- import BackgroundGeolocation, {
115
- State,
116
- Config,
117
- Location,
118
- LocationError,
119
- Geofence,
120
- GeofenceEvent,
121
- GeofencesChangeEvent,
122
- HeartbeatEvent,
123
- HttpEvent,
124
- MotionActivityEvent,
125
- MotionChangeEvent,
126
- ProviderChangeEvent,
127
- ConnectivityChangeEvent
128
- } from "react-native-background-geolocation";
119
+ ## :large_blue_diamond: Using the plugin ##
129
120
 
121
+ ```javascript
122
+ import BackgroundGeolocation from "react-native-background-geolocation";
130
123
  ```
131
124
 
132
- For more information, see [this blog post](https://medium.com/@transistorsoft/new-feature-typescript-api-4a160a2c853b)
133
-
134
125
  ## :large_blue_diamond: Example
135
126
 
136
127
  There are three main steps to using `BackgroundGeolocation`
@@ -139,32 +130,29 @@ There are three main steps to using `BackgroundGeolocation`
139
130
  3. `.start()` the plugin.
140
131
 
141
132
  > [!WARNING]
142
- > Do not execute *any* API method which will require accessing location-services until the **[`.ready(config)`](https://transistorsoft.github.io/react-native-background-geolocation/classes/backgroundgeolocation.html#ready)** method resolves ([Read its API docs](https://transistorsoft.github.io/react-native-background-geolocation/classes/backgroundgeolocation.html#ready)), For example:
133
+ > Do not execute *any* API method which will require accessing location-services until the **[`.ready(config)`](https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/BackgroundGeolocation.html#ready)** method resolves ([Read its API docs](https://transistorsoft.github.io/react-native-background-geolocation/latest/interfaces/BackgroundGeolocation.html#ready)), For example:
143
134
  >- `.getCurrentPosition`
144
135
  >- `.watchPosition`
145
136
  >- `.start`
146
137
 
147
138
  ```javascript
148
139
  // NO! .ready() has not resolved.
149
- BackgroundGeolocation.getCurrentPosition(options);
150
- BackgroundGeolocation.start();
140
+ await BackgroundGeolocation.getCurrentPosition(options);
141
+ await BackgroundGeolocation.start();
142
+
143
+ // First call .ready(config)
144
+ const state = await BackgroundGeolocation.ready(config);
145
+ const location = await BackgroundGeolocation.getCurrentPosition(options);
146
+ await BackgroundGeolocation.start();
151
147
 
152
- BackgroundGeolocation.ready(config).then((state) => {
153
- // YES -- .ready() has now resolved.
154
- BackgroundGeolocation.getCurrentPosition(options);
155
- BackgroundGeolocation.start();
156
- });
157
148
 
158
149
  // NO! .ready() has not resolved.
159
- BackgroundGeolocation.getCurrentPosition(options);
160
- BackgroundGeolocation.start();
150
+ const location = await BackgroundGeolocation.getCurrentPosition(options);
151
+ await BackgroundGeolocation.start();
161
152
  ```
162
153
 
163
154
 
164
- ### Example 1. &mdash; React *Functional Component*
165
-
166
- <details>
167
- <summary>Show Source</summary>
155
+ ### Example
168
156
 
169
157
  ```javascript
170
158
 
@@ -206,24 +194,32 @@ const HelloWorld = () => {
206
194
  /// 2. ready the plugin.
207
195
  BackgroundGeolocation.ready({
208
196
  // Geolocation Config
209
- desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
210
- distanceFilter: 10,
211
- // Activity Recognition
212
- stopTimeout: 5,
213
- // Application config
214
- debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
215
- logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
216
- stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
217
- startOnBoot: true, // <-- Auto start tracking when device is powered-up.
218
- // HTTP / SQLite config
219
- url: 'http://yourserver.com/locations',
220
- batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
221
- autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
222
- headers: { // <-- Optional HTTP headers
223
- "X-FOO": "bar"
197
+ geolocation: {
198
+ desiredAccuracy: BackgroundGeolocation.DesiredAccuracy.High
199
+ distanceFilter: 10,
200
+ stopTimeout: 5
201
+ },
202
+ // Logger Config
203
+ logger: {
204
+ debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
205
+ logLevel: BackgroundGeolocation.LogLevel.Verbose
224
206
  },
225
- params: { // <-- Optional HTTP params
226
- "auth_token": "maybe_your_server_authenticates_via_token_YES?"
207
+ // Application config
208
+ app: {
209
+ stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
210
+ startOnBoot: true // <-- Auto start tracking when device is powered-up.
211
+ },
212
+ // Http Config
213
+ http: {
214
+ url: 'http://yourserver.com/locations',
215
+ batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
216
+ autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
217
+ headers: { // <-- Optional HTTP headers
218
+ "X-FOO": "bar"
219
+ },
220
+ params: { // <-- Optional HTTP params
221
+ "auth_token": "maybe_your_server_authenticates_via_token_YES?"
222
+ }
227
223
  }
228
224
  }).then((state) => {
229
225
  setEnabled(state.enabled)
@@ -263,157 +259,10 @@ const HelloWorld = () => {
263
259
  export default HelloWorld;
264
260
  ```
265
261
 
266
- </details>
267
-
268
- ### Example 2. &mdash; React *Class Component*
269
-
270
- <details>
271
- <summary>Show Source</summary>
272
-
273
- ```javascript
274
- import React from 'react';
275
- import {
276
- Switch,
277
- Text,
278
- View,
279
- } from 'react-native';
280
-
281
- import BackgroundGeolocation, {
282
- Location,
283
- Subscription
284
- } from "react-native-background-geolocation";
285
-
286
- export default class HelloWorld extends React.Component {
287
- subscriptions:Subscription[] = [];
288
- state:any = {};
289
- constructor(props:any) {
290
- super(props);
291
- this.state = {
292
- enabled: false,
293
- location: ''
294
- }
295
- }
296
-
297
- componentDidMount() {
298
- /// 1. Subscribe to BackgroundGeolocation events.
299
- this.subscriptions.push(BackgroundGeolocation.onLocation((location) => {
300
- console.log('[onLocation]', location);
301
- this.setState({location: JSON.stringify(location, null, 2)})
302
- }, (error) => {
303
- console.log('[onLocation] ERROR:', error);
304
- }))
305
-
306
- this.subscriptions.push(BackgroundGeolocation.onMotionChange((event) => {
307
- console.log('[onMotionChange]', event);
308
- }))
309
-
310
- this.subscriptions.push(BackgroundGeolocation.onActivityChange((event) => {
311
- console.log('[onActivityChange]', event);
312
- }))
313
-
314
- this.subscriptions.push(BackgroundGeolocation.onProviderChange((event) => {
315
- console.log('[onProviderChange]', event);
316
- }))
317
-
318
- /// 2. ready the plugin.
319
- BackgroundGeolocation.ready({
320
- // Geolocation Config
321
- desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
322
- distanceFilter: 10,
323
- // Activity Recognition
324
- stopTimeout: 5,
325
- // Application config
326
- debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
327
- logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
328
- stopOnTerminate: false, // <-- Allow the background-service to continue tracking when user closes the app.
329
- startOnBoot: true, // <-- Auto start tracking when device is powered-up.
330
- // HTTP / SQLite config
331
- url: 'http://yourserver.com/locations',
332
- batchSync: false, // <-- [Default: false] Set true to sync locations to server in a single HTTP request.
333
- autoSync: true, // <-- [Default: true] Set true to sync each location to server as it arrives.
334
- headers: { // <-- Optional HTTP headers
335
- "X-FOO": "bar"
336
- },
337
- params: { // <-- Optional HTTP params
338
- "auth_token": "maybe_your_server_authenticates_via_token_YES?"
339
- }
340
- }).then((state) => {
341
- this.setState({enabled: state.enabled});
342
- console.log("- BackgroundGeolocation is configured and ready: ", state.enabled);
343
- })
344
- }
345
-
346
- /// When view is destroyed (or refreshed during development live-reload),
347
- /// remove BackgroundGeolocation event subscriptions.
348
- componentWillUnmount() {
349
- this.subscriptions.forEach((subscription) => subscription.remove());
350
- }
351
-
352
- onToggleEnabled(value:boolean) {
353
- console.log('[onToggleEnabled]', value);
354
- this.setState({enabled: value})
355
- if (value) {
356
- BackgroundGeolocation.start();
357
- } else {
358
- this.setState({location: ''});
359
- BackgroundGeolocation.stop();
360
- }
361
- }
362
-
363
- render() {
364
- return (
365
- <View style={{alignItems:'center'}}>
366
- <Text>Click to enable BackgroundGeolocation</Text>
367
- <Switch value={this.state.enabled} onValueChange={this.onToggleEnabled.bind(this)} />
368
- <Text style={{fontFamily:'monospace', fontSize:12}}>{this.state.location}</Text>
369
- </View>
370
- )
371
- }
372
- }
373
- ```
374
- </details>
375
-
376
- ### Promise API
377
-
378
- 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)
379
-
380
- ```javascript
381
- BackgroundGeolocation.ready({
382
- desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
383
- distanceFilter: 50
384
- }).then(state => {
385
- console.log('- BackgroundGeolocation is ready: ', state);
386
- }).catch(error => {
387
- console.warn('- BackgroundGeolocation error: ', error);
388
- });
389
-
390
- // Or use await in an async function
391
- try {
392
- const state = await BackgroundGeolocation.ready({
393
- desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
394
- distanceFilter: 50
395
- })
396
- console.log('- BackgroundGeolocation is ready: ', state);
397
- } catch (error) {
398
- console.warn('- BackgroundGeolocation error: ', error);
399
- }
400
- ```
401
-
402
- ## :large_blue_diamond: [Demo Application](https://github.com/transistorsoft/rn-background-geolocation-demo)
403
-
404
- A fully-featured [Demo App](https://github.com/transistorsoft/rn-background-geolocation-demo) is available in its own public repo. After first cloning that repo, follow the installation instructions in the **README** there. This demo-app includes a settings-screen allowing you to quickly experiment with all the different settings available for each platform.
405
-
406
- ![Home](https://dl.dropboxusercontent.com/s/wa43w1n3xhkjn0i/home-framed-350.png?dl=1)
407
- ![Settings](https://dl.dropboxusercontent.com/s/8oad228siog49kt/settings-framed-350.png?dl=1)
408
-
409
-
410
- ## :large_blue_diamond: [Simple Testing Server](https://github.com/transistorsoft/background-geolocation-console)
411
-
412
- A simple Node-based [web-application](https://github.com/transistorsoft/background-geolocation-console) with SQLite database is available for field-testing and performance analysis. If you're familiar with Node, you can have this server up-and-running in about **one minute**.
262
+ ## :large_blue_diamond: [Demo Application](example)
413
263
 
414
- ![](https://dl.dropboxusercontent.com/s/px5rzz7wybkv8fs/background-geolocation-console-map.png?dl=1)
264
+ Clone this repo and run the [/example](example) app.
415
265
 
416
- ![](https://dl.dropboxusercontent.com/s/tiy5b2oivt0np2y/background-geolocation-console-grid.png?dl=1)
417
266
 
418
267
  # License
419
268
 
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
27
27
  s.preserve_paths = 'docs', 'CHANGELOG.md', 'LICENSE', 'package.json', 'RNBackgroundGeolocation.ios.js'
28
28
 
29
29
  s.dependency 'CocoaLumberjack', '~> 3.8.5'
30
- s.dependency 'TSLocationManager', '~> 4.0.0-beta.5'
30
+ s.dependency 'TSLocationManager', '~> 4.0.0'
31
31
 
32
32
  s.libraries = 'sqlite3', 'z', 'stdc++'
33
33
  s.resource_bundles = {
@@ -42,4 +42,4 @@ Pod::Spec.new do |s|
42
42
  else
43
43
  s.dependency 'React-Core'
44
44
  end
45
- end
45
+ end
@@ -9,6 +9,7 @@ def DEFAULT_TARGET_SDK_VERSION = 36
9
9
 
10
10
  // Plugin dependencies
11
11
  def DEFAULT_PLAY_SERVICES_LOCATION_VERSION = "21.3.0"
12
+ def DEFAULT_TSLOCATIONMANAGER_VERSION = "4.0.+"
12
13
  def DEFAULT_OK_HTTP_VERSION = "4.12.0"
13
14
  def DEFAULT_ANDROID_PERMISSIONS_VERSION = "2.1.6"
14
15
  def DEFAULT_EVENTBUS_VERSION = "3.3.1"
@@ -60,9 +61,16 @@ repositories{
60
61
 
61
62
  dependencies {
62
63
  def playServicesLocationVersion = safeExtGet('playServicesLocationVersion', safeExtGet('googlePlayServicesLocationVersion', DEFAULT_PLAY_SERVICES_LOCATION_VERSION))
63
-
64
+ def tslocationmanagerVersion = safeExtGet('tslocationmanagerVersion', DEFAULT_TSLOCATIONMANAGER_VERSION)
64
65
  implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
65
- implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
66
- implementation "com.transistorsoft:tslocationmanager:4.0.0-beta.+"
66
+
67
+ def locationMajorVersion = playServicesLocationVersion.split('\\.')[0] as int
68
+ if (locationMajorVersion >= 21) {
69
+ api "com.transistorsoft:tslocationmanager:$tslocationmanagerVersion"
70
+ } else {
71
+ api "com.transistorsoft:tslocationmanager-gms20:$tslocationmanagerVersion"
72
+ }
73
+
74
+ implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
67
75
  implementation 'org.greenrobot:eventbus:3.3.1'
68
76
  }
@@ -1,84 +1,49 @@
1
- # JNI surface
2
- -keepnames class com.transistorsoft.locationmanager.a.A
3
- -keepclassmembers class com.transistorsoft.locationmanager.a.A {
4
- public static void r(boolean);
5
- public static boolean getDBFlag();
6
- }
7
- #######################################################################
8
- # TSConfig reflection (metadata + state + editors)
9
- #######################################################################
10
- -keepattributes *Annotation*,Signature,EnclosingMethod,InnerClasses
11
-
12
- # Keep the annotation TYPES so they exist at runtime
13
- -keep class com.transistorsoft.locationmanager.config.meta.ConfigProp { *; }
14
- -keep class com.transistorsoft.locationmanager.config.meta.ConfigSpec { *; }
15
- -keep class com.transistorsoft.locationmanager.config.meta.ConfigGroup { *; }
16
- -keep class com.transistorsoft.locationmanager.config.meta.CtorOrder { *; }
1
+ -keepnames class com.facebook.react.ReactActivity
17
2
 
18
- # Keep field names + ctors for state modules; FieldIndex uses getters/ctors by name/signature
19
- -keepnames class com.transistorsoft.locationmanager.config.state.** { *; }
20
- -keepclassmembers class com.transistorsoft.locationmanager.config.state.** {
21
- <fields>;
22
- <init>(...);
3
+ # for react-native Headless on new architecture
4
+ -keep class com.facebook.react.defaults.DefaultNewArchitectureEntryPoint {
5
+ public <methods>;
23
6
  }
24
-
25
- # Keep module field names on the aggregate ConfigState
26
- -keepnames class com.transistorsoft.locationmanager.config.state.ConfigState {
27
- <fields>;
28
- <init>(...);
7
+ -keep class com.facebook.react.ReactApplication {
8
+ public <methods>;
29
9
  }
30
-
31
- # Keep Editor and sub-editors members that routing may reflect
32
- -keepnames class com.transistorsoft.locationmanager.config.edit.Editor { *; }
33
- -keepclassmembers class com.transistorsoft.locationmanager.config.edit.Editor {
34
- <fields>;
35
- <init>(...);
10
+ -keep class com.facebook.react.ReactHost {
11
+ public <methods>;
36
12
  }
37
- -keepclassmembers class com.transistorsoft.locationmanager.config.edit.** {
38
- public <init>(...);
39
- public ** set*(...);
40
- <fields>;
13
+ -keep class * extends com.facebook.react.ReactHost {
14
+ public <methods>;
41
15
  }
42
- -keepnames class com.transistorsoft.locationmanager.config.TSConfig
43
- -keepclassmembers class com.transistorsoft.locationmanager.config.TSConfig { public static void r(boolean); }
44
- -keepnames class com.transistorsoft.locationmanager.logger.TSLog
45
- -keepclassmembers class com.transistorsoft.locationmanager.logger.TSLog { public static void r(boolean); }
46
- -keepnames class com.transistorsoft.locationmanager.service.AbstractService
47
- -keepclassmembers class com.transistorsoft.locationmanager.service.AbstractService { public static void r(boolean); }
16
+ -keep class com.facebook.react.fabric.** { *; }
48
17
 
49
- # Services (names + ctors)
50
- -keep class com.transistorsoft.locationmanager.service.** extends com.transistorsoft.locationmanager.service.AbstractService
51
- -keepclassmembers class com.transistorsoft.locationmanager.service.** extends com.transistorsoft.locationmanager.service.AbstractService { <init>(...); }
18
+ -keepnames class com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocation
52
19
 
53
- # Scheduler components
54
- -keep class com.transistorsoft.locationmanager.scheduler.ScheduleAlarmReceiver
55
- -keep class com.transistorsoft.locationmanager.scheduler.ScheduleJobService
56
- -keep class com.transistorsoft.locationmanager.scheduler.ScheduleService
57
- -keepclassmembers class com.transistorsoft.locationmanager.scheduler.ScheduleAlarmReceiver { <init>(...); }
58
- -keepclassmembers class com.transistorsoft.locationmanager.scheduler.ScheduleJobService { <init>(...); }
59
- -keepclassmembers class com.transistorsoft.locationmanager.scheduler.ScheduleService { <init>(...); }
20
+ -keep class com.transistorsoft** { *; }
21
+ -dontwarn com.transistorsoft.**
60
22
 
61
- # Cross-module DTOs
62
- -keepnames class com.transistorsoft.locationmanager.data.SQLQuery
63
- -keepclassmembers class com.transistorsoft.locationmanager.data.SQLQuery { public static *; }
64
- -keepnames class com.transistorsoft.locationmanager.data.LocationModel
65
- -keepclassmembers class com.transistorsoft.locationmanager.data.LocationModel { public *; }
66
-
67
- # EventBus reflection
23
+ # BackgroundGeolocation (EventBus)
68
24
  -keepattributes *Annotation*
69
- -keepclassmembers class * { @org.greenrobot.eventbus.Subscribe <methods>; }
25
+ -keepclassmembers class * {
26
+ @org.greenrobot.eventbus.Subscribe <methods>;
27
+ }
70
28
  -keep enum org.greenrobot.eventbus.ThreadMode { *; }
71
- -keep class org.greenrobot.eventbus.android.AndroidComponentsImpl
72
29
 
73
- # (Optional) Flutter plugin entry
74
- -keepnames class com.transistorsoft.flutter.backgroundgeolocation.FLTBackgroundGeolocationPlugin
30
+ # And if you use AsyncExecutor:
31
+ -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
32
+ <init>(java.lang.Throwable);
33
+ }
75
34
 
76
- # OkHttp/logging quiets (unchanged)
35
+ # logback
36
+ -keep class ch.qos** { *; }
37
+ -keep class org.slf4j** { *; }
38
+ -dontwarn ch.qos.logback.core.net.*
39
+
40
+ # OkHttp3
77
41
  -dontwarn okio.**
78
42
  -dontwarn okhttp3.**
79
43
  -dontwarn javax.annotation.**
80
44
  -dontwarn org.conscrypt.**
45
+ # A resource is loaded with a relative path so the package of this class must be preserved.
81
46
  -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
82
- -keep class ch.qos** { *; }
83
- -keep class org.slf4j** { *; }
84
- -dontwarn ch.qos.logback.core.net.*
47
+
48
+ # LifecycleObserver
49
+ -keep class androidx.lifecycle.FullLifecycleObserver
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
- "name": "react-native-background-geolocation",
3
- "version": "5.0.0-beta.3",
2
+
3
+ "name": "react-native-background-geolocation",
4
+ "version": "5.0.0",
4
5
  "description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence",
5
6
  "scripts": {
6
7
  "build": "yarn run build:expo",
7
8
  "test": "echo \"Error: no test specified\" && exit 1",
8
9
  "build:expo": "rimraf expo/plugin/build && tsc --build ./expo/plugin",
9
10
  "docs": "node ./scripts/generate-docs.mjs",
10
- "docs:publish": "./scripts/publish-docs.sh"
11
+ "docs:publish": "./scripts/publish-docs.sh",
12
+ "prepublishOnly": "npm run build"
11
13
  },
12
14
  "codegenConfig": {
13
15
  "name": "RNBackgroundGeolocation",
@@ -19,7 +21,7 @@
19
21
  "ios": {
20
22
  "swiftModuleName": "RNBackgroundGeolocation",
21
23
  "packageName": "RNBackgroundGeolocation"
22
- }
24
+ }
23
25
  },
24
26
  "main": "src/index.js",
25
27
  "repository": {
package/src/Logger.js CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  import NativeModule from "./NativeModule";
5
5
 
6
- const RNBackgroundGeolocation = NativeModule; // uses the same getNativeBGGeo() under the hood
7
-
8
6
  const LOG_LEVEL_DEBUG = "debug";
9
7
  const LOG_LEVEL_NOTICE = "notice";
10
8
  const LOG_LEVEL_INFO = "info";
@@ -15,12 +13,19 @@ const ORDER_ASC = 1;
15
13
  const ORDER_DESC = -1;
16
14
 
17
15
  function log(level, msg) {
18
- // You can either:
19
- // 1) call the native logger via NativeModule.logger
20
- // NativeModule.logger[level](msg);
21
- // or
22
- // 2) just use the native `log` directly if exposed:
23
- RNBackgroundGeolocation.log(level, msg);
16
+ // Call the native logger via NativeModule.logger[level](msg),
17
+ // fallback to debug if missing.
18
+ if (
19
+ NativeModule.logger &&
20
+ typeof NativeModule.logger[level] === 'function'
21
+ ) {
22
+ NativeModule.logger[level](msg);
23
+ } else if (
24
+ NativeModule.logger &&
25
+ typeof NativeModule.logger.debug === 'function'
26
+ ) {
27
+ NativeModule.logger.debug(msg);
28
+ }
24
29
  }
25
30
 
26
31
  function validateQuery(query) {
@@ -45,18 +50,18 @@ export default class Logger {
45
50
  static notice(msg) { log(LOG_LEVEL_NOTICE, msg); }
46
51
 
47
52
  static getLog(query) {
48
- return RNBackgroundGeolocation.getLog(validateQuery(query));
53
+ return NativeModule.getLog(validateQuery(query));
49
54
  }
50
55
 
51
56
  static emailLog(email, query) {
52
- return RNBackgroundGeolocation.emailLog(email, validateQuery(query));
57
+ return NativeModule.emailLog(email, validateQuery(query));
53
58
  }
54
59
 
55
60
  static uploadLog(url, query) {
56
- return RNBackgroundGeolocation.uploadLog(url, validateQuery(query));
61
+ return NativeModule.uploadLog(url, validateQuery(query));
57
62
  }
58
63
 
59
64
  static destroyLog() {
60
- return RNBackgroundGeolocation.destroyLog();
65
+ return NativeModule.destroyLog();
61
66
  }
62
67
  }
@@ -395,16 +395,20 @@ export default class NativeModule {
395
395
  return RNBackgroundGeolocation.setLogLevel(value);
396
396
  }
397
397
 
398
- static getLog() {
399
- return RNBackgroundGeolocation.getLog();
398
+ static getLog(query) {
399
+ return RNBackgroundGeolocation.getLog(query);
400
400
  }
401
401
 
402
402
  static destroyLog() {
403
- return RNBackgroundGeolocation.destroyLog();
403
+ return RNBackgroundGeolocation.destroyLog();
404
404
  }
405
405
 
406
406
  static emailLog(email, query) {
407
- return RNBackgroundGeolocation.emailLog(email, query);
407
+ return RNBackgroundGeolocation.emailLog(email, query);
408
+ }
409
+
410
+ static uploadLog(url, query) {
411
+ return RNBackgroundGeolocation.uploadLog(url, query);
408
412
  }
409
413
 
410
414
  static isPowerSaveMode() {
@@ -35,6 +35,11 @@ declare module "react-native-background-geolocation" {
35
35
  * - [[getOdometer]]
36
36
  */
37
37
  odometer: number;
38
+ /**
39
+ * The estimated error (in meters) of the current odometer value.
40
+ */
41
+ odometerError: number;
42
+
38
43
  /**
39
44
  * `true` when the iOS app was launched in the background. Always `false` for Android.
40
45
  * iOS apps can be launched in the background due to a background-fetch event, geofence events or exiting the [[Config.stationaryRadius]].
@@ -44,6 +44,10 @@ export interface Spec extends TurboModule {
44
44
 
45
45
  // Logging
46
46
  log(level: string, message: string): Promise<void>;
47
+ getLog(query: Object): Promise<string>;
48
+ emailLog(email: string, query: Object): Promise<void>;
49
+ uploadLog(url: string, query: Object): Promise<void>;
50
+ destroyLog(): Promise<void>;
47
51
  }
48
52
 
49
53
  export default TurboModuleRegistry.getEnforcing<Spec>('RNBackgroundGeolocation');