@josuelmm/cordova-background-geolocation 4.2.0 → 4.2.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.2.2](https://github.com/josuelmm/cordova-background-geolocation/tree/4.2.2) (2026-05-09)
4
+
5
+ ### Fixed
6
+ - `PostLocationTask.postLocation`: cast del retorno de `LocationTemplate.locationToJson` (que es `Object` — `JSONObject` para `HashMapLocationTemplate`, `JSONArray` para `ArrayListLocationTemplate`) a la sobrecarga correcta de `HttpPostService.postJSON`. Bug latente que rompía la compilación con consumidores Capacitor (Gradle 8.x).
7
+ - `BackgroundGeolocationPlugin.buildDiagnostics`: envolver `facade.locationServicesEnabled()` en `try/catch (PluginException)`. El método declara `throws JSONException` pero no `PluginException`, lo que rompía el build cuando se invoca desde `getDiagnostics`.
8
+
3
9
  ## [4.2.0](https://github.com/josuelmm/cordova-background-geolocation/tree/4.2.0) (2026-05-08)
4
10
 
5
11
  ### Phase 8 — Real sensor fusion (accelerometer + gyroscope)
package/HISTORY.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  **for cordova-plugin-background-geolocation**
4
4
 
5
+ ## [4.2.2] - 2026-05-09
6
+
7
+ ### Fixed
8
+ - `PostLocationTask`: handle `LocationTemplate.locationToJson` returning `Object` (JSONObject vs JSONArray) — fixed compile failure under Capacitor / Gradle 8.x.
9
+ - `BackgroundGeolocationPlugin.buildDiagnostics`: wrap `facade.locationServicesEnabled()` in `try/catch (PluginException)` — fixed unreported-checked-exception build error.
10
+ - Plugin version: `4.2.2`.
11
+
5
12
  ## [4.2.0] - 2026-05-08
6
13
 
7
14
  ### Phase 8 — Real sensor fusion (accelerometer + gyroscope)
package/README.md CHANGED
@@ -368,6 +368,12 @@ Subscribe with `BackgroundGeolocation.on(eventName, callback)`. Unsubscribe with
368
368
 
369
369
  Full event payloads and options: [Events](docs/events.md). Full API (all options, all methods): [API](docs/api.md).
370
370
 
371
+ ### New in 4.2.2
372
+
373
+ - Build hotfixes — required when consuming the plugin via Capacitor (Gradle 8.x):
374
+ - `PostLocationTask.postLocation`: cast `LocationTemplate.locationToJson` (returns `Object`) to the right `HttpPostService.postJSON` overload.
375
+ - `BackgroundGeolocationPlugin.buildDiagnostics`: wrap `facade.locationServicesEnabled()` in `try/catch (PluginException)`.
376
+
371
377
  ### New in 4.2.0
372
378
 
373
379
  - **Real sensor fusion (Phase 8).** Optional accelerometer + gyroscope pipeline (`drivingEvents.sensorFusion: true`). On Android uses `Sensor.TYPE_LINEAR_ACCELERATION` + `Sensor.TYPE_GYROSCOPE`; on iOS uses `CMMotionManager.startDeviceMotionUpdatesToQueue` at 50 Hz.
@@ -89,7 +89,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Plugin
89
89
  public static final String ACTION_TRIGGER_SOS = "triggerSOS";
90
90
 
91
91
  /** Plugin version; keep in sync with plugin.xml. */
92
- public static final String PLUGIN_VERSION = "4.2.0";
92
+ public static final String PLUGIN_VERSION = "4.2.2";
93
93
 
94
94
  private BackgroundGeolocationFacade facade;
95
95
 
@@ -519,7 +519,11 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Plugin
519
519
 
520
520
  // Common
521
521
  d.put("isRunning", facade.isRunning());
522
- d.put("locationServicesEnabled", facade.locationServicesEnabled());
522
+ try {
523
+ d.put("locationServicesEnabled", facade.locationServicesEnabled());
524
+ } catch (PluginException e) {
525
+ d.put("locationServicesEnabled", JSONObject.NULL);
526
+ }
523
527
 
524
528
  try {
525
529
  Config cfg = facade.getConfig();
@@ -168,7 +168,10 @@ public class PostLocationTask {
168
168
  private boolean postLocation(BackgroundLocation location) {
169
169
  logger.debug("Executing PostLocationTask#postLocation");
170
170
 
171
- JSONObject jsonLocation;
171
+ // LocationTemplate.locationToJson returns Object (JSONObject for HashMapLocationTemplate,
172
+ // JSONArray for ArrayListLocationTemplate). Resolve to the concrete type before calling
173
+ // the matching HttpPostService.postJSON overload.
174
+ Object jsonLocation;
172
175
  try {
173
176
  jsonLocation = mConfig.getTemplate().locationToJson(location);
174
177
  } catch (JSONException e) {
@@ -186,13 +189,17 @@ public class PostLocationTask {
186
189
  String method = mConfig.getHttpMethod();
187
190
  String mode = mConfig.getHttpMode();
188
191
  logger.debug("Posting to url: {} method: {} mode: {} headers: {}",
189
- resolvedUrl, method, mode, mConfig.getHttpHeaders());
192
+ resolvedUrl, method, mConfig.getHttpHeaders());
190
193
  int responseCode;
191
194
 
192
195
  try {
193
196
  if ("single".equals(mode) || "GET".equals(method)) {
194
197
  // GET cannot carry a JSON array body; force per-location request.
195
- responseCode = HttpPostService.postJSON(resolvedUrl, jsonLocation, mConfig.getHttpHeaders(), method);
198
+ if (jsonLocation instanceof JSONArray) {
199
+ responseCode = HttpPostService.postJSON(resolvedUrl, (JSONArray) jsonLocation, mConfig.getHttpHeaders(), method);
200
+ } else {
201
+ responseCode = HttpPostService.postJSON(resolvedUrl, (JSONObject) jsonLocation, mConfig.getHttpHeaders(), method);
202
+ }
196
203
  } else {
197
204
  JSONArray jsonLocations = new JSONArray();
198
205
  jsonLocations.put(jsonLocation);
@@ -513,7 +513,7 @@ static NSString * const TAG = @"CDVBackgroundGeolocation";
513
513
  - (void) getPluginVersion:(CDVInvokedUrlCommand*)command
514
514
  {
515
515
  NSLog(@"%@ #%@", TAG, @"getPluginVersion");
516
- NSString *version = @"4.2.0"; // keep in sync with plugin.xml and Android PLUGIN_VERSION
516
+ NSString *version = @"4.2.2"; // keep in sync with plugin.xml and Android PLUGIN_VERSION
517
517
  CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
518
518
  [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
519
519
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josuelmm/cordova-background-geolocation",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Cordova Background Geolocation (fork actualizado)",
5
5
  "main": "./www/BackgroundGeolocation.js",
6
6
  "types": "./www/BackgroundGeolocation.d.ts",
@@ -99,6 +99,11 @@
99
99
  "cordova": ">=10.0.0",
100
100
  "cordova-android": ">=12.0.0",
101
101
  "cordova-ios": ">=6.2.0"
102
+ },
103
+ "4.2.2": {
104
+ "cordova": ">=10.0.0",
105
+ "cordova-android": ">=12.0.0",
106
+ "cordova-ios": ">=6.2.0"
102
107
  }
103
108
  }
104
109
  },
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova-background-geolocation"
5
- version="4.2.0">
5
+ version="4.2.2">
6
6
  <name>cordova-background-geolocation</name>
7
7
  <description>Cordova Background Geolocation Plugin</description>
8
8
  <license>Apache-2.0</license>