react-native-background-geolocation 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,14 +21,14 @@ The SDK uses **motion-detection** APIs (accelerometer, gyroscope, magnetometer)
21
21
  ## :books: Documentation
22
22
 
23
23
  ### <img src="assets/images/platforms/react-native.svg" width="20" height="20"> React Native
24
- - [Setup](https://docs.transistorsoft.com/typescript/setup/?tab=react-native)
25
- - [API Reference](https://docs.transistorsoft.com/typescript/BackgroundGeolocation/)
26
- - [Example](https://docs.transistorsoft.com/typescript/examples/?tab=react-native)
24
+ - [Setup](https://docs.transistorsoft.com/react-native/setup/)
25
+ - [API Reference](https://docs.transistorsoft.com/react-native/BackgroundGeolocation/)
26
+ - [Example](https://docs.transistorsoft.com/react-native/examples/)
27
27
 
28
28
  ### <img src="assets/images/platforms/expo.svg" width="20" height="20"> Expo
29
- - [Setup](https://docs.transistorsoft.com/typescript/setup/?tab=expo)
30
- - [API Reference](https://docs.transistorsoft.com/typescript/BackgroundGeolocation/)
31
- - [Example](https://docs.transistorsoft.com/typescript/examples/?tab=react-native)
29
+ - [Setup](https://docs.transistorsoft.com/react-native/setup/)
30
+ - [API Reference](https://docs.transistorsoft.com/react-native/BackgroundGeolocation/)
31
+ - [Example](https://docs.transistorsoft.com/react-native/examples/)
32
32
 
33
33
  ---
34
34
 
@@ -38,7 +38,7 @@ The SDK uses **motion-detection** APIs (accelerometer, gyroscope, magnetometer)
38
38
  > The SDK is **fully functional in `DEBUG` builds** — no license required. Try before you buy.
39
39
 
40
40
  A license is required only for **`RELEASE` builds** on Android.
41
- [Purchase a license](https://shop.transistorsoft.com/products/react-native-background-geolocation)
41
+ [Purchase a license](https://docs.transistorsoft.com)
42
42
 
43
43
  ---
44
44
 
@@ -57,8 +57,8 @@ See [`/example`](example/README.md) — example apps are included in this repo.
57
57
  | <img src="assets/images/platforms/flutter.svg" width="16" height="16"> [Flutter](https://github.com/transistorsoft/flutter_background_geolocation) | `flutter_background_geolocation` |
58
58
  | <img src="assets/images/platforms/capacitor.svg" width="16" height="16"> [Capacitor](https://github.com/transistorsoft/capacitor-background-geolocation) | `@transistorsoft/capacitor-background-geolocation` |
59
59
  | <img src="assets/images/platforms/cordova.svg" width="16" height="16"> [Cordova](https://github.com/transistorsoft/cordova-background-geolocation-lt) | `cordova-background-geolocation-lt` |
60
- | <img src="assets/images/platforms/swift.svg" width="16" height="16"> [Swift / iOS](https://github.com/transistorsoft/background-geolocation) | `background-geolocation` |
61
- | <img src="assets/images/platforms/kotlin.svg" width="16" height="16"> [Kotlin / Android](https://github.com/transistorsoft/background-geolocation) | `background-geolocation` |
60
+ | <img src="assets/images/platforms/swift.svg" width="16" height="16"> [Swift / iOS](https://github.com/transistorsoft/native-background-geolocation) | `background-geolocation` |
61
+ | <img src="assets/images/platforms/kotlin.svg" width="16" height="16"> [Kotlin / Android](https://github.com/transistorsoft/native-background-geolocation) | `background-geolocation` |
62
62
 
63
63
  ---
64
64
 
@@ -26,7 +26,8 @@ Pod::Spec.new do |s|
26
26
  s.source_files = 'ios/RNBackgroundGeolocation/*.{h,m,mm}'
27
27
  s.preserve_paths = 'docs', 'CHANGELOG.md', 'LICENSE', 'package.json', 'RNBackgroundGeolocation.ios.js'
28
28
 
29
- s.dependency 'TSLocationManager', '~> 4.1.0'
29
+ tslm_version = ENV['TSLOCATIONMANAGER_VERSION'] || '~> 4.2.0'
30
+ s.dependency 'TSLocationManager', tslm_version
30
31
 
31
32
  s.libraries = 'sqlite3', 'z', 'stdc++'
32
33
  s.resource_bundles = {
@@ -9,7 +9,7 @@ def DEFAULT_TARGET_SDK_VERSION = 35
9
9
 
10
10
  // Plugin dependencies
11
11
  def DEFAULT_PLAY_SERVICES_LOCATION_VERSION = "21.3.0"
12
- def DEFAULT_TSLOCATIONMANAGER_VERSION = "4.1.+"
12
+ def DEFAULT_TSLOCATIONMANAGER_VERSION = "4.2.+"
13
13
  def DEFAULT_OK_HTTP_VERSION = "4.12.0"
14
14
  def DEFAULT_ANDROID_PERMISSIONS_VERSION = "2.1.6"
15
15
  def DEFAULT_EVENTBUS_VERSION = "3.3.1"
@@ -62,6 +62,8 @@ public class HeadlessTask {
62
62
  params = event.getProviderChangeEvent().toMap();
63
63
  } else if (name.equals(EventName.ACTIVITYCHANGE)) {
64
64
  params = event.getActivityChangeEvent().toMap();
65
+ } else if (name.equals(EventName.LOCATIONFILTER)) {
66
+ params = event.getLocationFilterEvent().toMap();
65
67
  } else if (name.equals(EventName.SCHEDULE)) {
66
68
  params = config.toMap(false);
67
69
  } else if (name.equals(EventName.BOOT)) {
@@ -47,6 +47,7 @@ import com.transistorsoft.locationmanager.data.LocationModel;
47
47
  import com.transistorsoft.locationmanager.data.SQLQuery;
48
48
  import com.transistorsoft.locationmanager.device.DeviceInfo;
49
49
  import com.transistorsoft.locationmanager.event.ActivityChangeEvent;
50
+ import com.transistorsoft.locationmanager.event.LocationFilterEvent;
50
51
  import com.transistorsoft.locationmanager.event.AuthorizationEvent;
51
52
  import com.transistorsoft.locationmanager.event.ConnectivityChangeEvent;
52
53
  import com.transistorsoft.locationmanager.event.GeofenceEvent;
@@ -118,6 +119,7 @@ public class RNBackgroundGeolocationModule
118
119
  mEvents.add(EventName.LOCATION);
119
120
  mEvents.add(EventName.MOTIONCHANGE);
120
121
  mEvents.add(EventName.ACTIVITYCHANGE);
122
+ mEvents.add(EventName.LOCATIONFILTER);
121
123
  mEvents.add(EventName.PROVIDERCHANGE);
122
124
  mEvents.add(EventName.GEOFENCESCHANGE);
123
125
  mEvents.add(EventName.GEOFENCE);
@@ -146,6 +148,7 @@ public class RNBackgroundGeolocationModule
146
148
  adapter.onLocation(new LocationCallback());
147
149
  adapter.onMotionChange(new MotionChangeCallback());
148
150
  adapter.onActivityChange(new ActivityChangeCallback());
151
+ adapter.onLocationFilter(new LocationFilterCallback());
149
152
  adapter.onLocationProviderChange(new LocationProviderChangeCallback());
150
153
  adapter.onGeofencesChange(new GeofencesChangeCallback());
151
154
  adapter.onGeofence(new GeofenceCallback());
@@ -199,6 +202,15 @@ public class RNBackgroundGeolocationModule
199
202
  }
200
203
  }
201
204
 
205
+ /**
206
+ * locationfilter event callback
207
+ */
208
+ private class LocationFilterCallback implements TSLocationFilterCallback {
209
+ @Override public void onLocationFilter(LocationFilterEvent event) {
210
+ sendEvent(EventName.LOCATIONFILTER, mapToWritableMap(event.toMap()));
211
+ }
212
+ }
213
+
202
214
  /**
203
215
  * providerchange event callback
204
216
  */
@@ -30,6 +30,7 @@ static NSString *const EVENT_WATCHPOSITION = @"watchposition";
30
30
  static NSString *const EVENT_PROVIDERCHANGE = @"providerchange";
31
31
  static NSString *const EVENT_MOTIONCHANGE = @"motionchange";
32
32
  static NSString *const EVENT_ACTIVITYCHANGE = @"activitychange";
33
+ static NSString *const EVENT_LOCATIONFILTER = @"locationfilter";
33
34
  static NSString *const EVENT_GEOFENCESCHANGE = @"geofenceschange";
34
35
  static NSString *const EVENT_HTTP = @"http";
35
36
  static NSString *const EVENT_SCHEDULE = @"schedule";
@@ -89,6 +90,9 @@ RCT_EXPORT_MODULE();
89
90
  NSDictionary *params = @{@"activity": event.activity, @"confidence": @(event.confidence)};
90
91
  [me sendEvent:EVENT_ACTIVITYCHANGE body:params];
91
92
  }];
93
+ [locationManager onLocationFilter:^(TSLocationFilterEvent *event) {
94
+ [me sendEvent:EVENT_LOCATIONFILTER body:[event toDictionary]];
95
+ }];
92
96
  [locationManager onHeartbeat:^(TSHeartbeatEvent *event) {
93
97
  [me sendEvent:EVENT_HEARTBEAT body:[event toDictionary]];
94
98
  }];
@@ -131,6 +135,7 @@ RCT_EXPORT_MODULE();
131
135
  EVENT_PROVIDERCHANGE,
132
136
  EVENT_MOTIONCHANGE,
133
137
  EVENT_ACTIVITYCHANGE,
138
+ EVENT_LOCATIONFILTER,
134
139
  EVENT_GEOFENCESCHANGE,
135
140
  EVENT_POWERSAVECHANGE,
136
141
  EVENT_HTTP,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "react-native-background-geolocation",
4
- "version": "5.1.0",
4
+ "version": "5.2.0",
5
5
  "description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence",
6
6
  "scripts": {
7
7
  "build": "yarn run build:expo",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@babel/runtime": "^7.26.0",
44
- "@transistorsoft/background-geolocation-types": "^5.0.1",
44
+ "@transistorsoft/background-geolocation-types": "^5.2.0",
45
45
  "tslib": "^2.6.3"
46
46
  },
47
47
  "author": "Chris Scott <chris@transistorsoft.com>",
package/src/index.js CHANGED
@@ -89,6 +89,7 @@ export default class BackgroundGeolocation {
89
89
  static get EVENT_HEARTBEAT() { return Event.Heartbeat; }
90
90
  static get EVENT_PROVIDERCHANGE() { return Event.ProviderChange; }
91
91
  static get EVENT_ACTIVITYCHANGE() { return Event.ActivityChange; }
92
+ static get EVENT_LOCATIONFILTER() { return Event.LocationFilter; }
92
93
  static get EVENT_GEOFENCE() { return Event.Geofence; }
93
94
  static get EVENT_GEOFENCESCHANGE() { return Event.GeofencesChange; }
94
95
  static get EVENT_ENABLEDCHANGE() { return Event.EnabledChange; }
@@ -275,6 +276,10 @@ export default class BackgroundGeolocation {
275
276
  return this.addListener(Event.ActivityChange, callback);
276
277
  }
277
278
 
279
+ static onLocationFilter(callback) {
280
+ return this.addListener(Event.LocationFilter, callback);
281
+ }
282
+
278
283
  static onGeofence(callback) {
279
284
  return this.addListener(Event.Geofence, callback);
280
285
  }
@@ -0,0 +1,30 @@
1
+ jest.mock('../src/NativeModule', () => ({
2
+ addListener: jest.fn(() => ({ remove: jest.fn() })),
3
+ }));
4
+
5
+ const NativeModule = require('../src/NativeModule');
6
+ const BG = require('../src/index.js').default;
7
+ const Shared = require('@transistorsoft/background-geolocation-types');
8
+
9
+ // onLocationFilter event wiring (issue #2585).
10
+ test('exposes the locationfilter event name + subscription method', () => {
11
+ // Shared enum carries the new event name.
12
+ expect(Shared.Event.LocationFilter).toBe('locationfilter');
13
+
14
+ // Backward-compat static getter mirrors the shared enum.
15
+ expect(BG.EVENT_LOCATIONFILTER).toBe('locationfilter');
16
+
17
+ // Subscription method is exposed.
18
+ expect(typeof BG.onLocationFilter).toBe('function');
19
+ });
20
+
21
+ test('onLocationFilter routes through the native bridge with the locationfilter event', () => {
22
+ NativeModule.addListener.mockClear();
23
+ const cb = jest.fn();
24
+
25
+ const subscription = BG.onLocationFilter(cb);
26
+
27
+ expect(NativeModule.addListener).toHaveBeenCalledWith('locationfilter', cb);
28
+ expect(subscription).toBeDefined();
29
+ expect(typeof subscription.remove).toBe('function');
30
+ });