@josuelmm/cordova-background-geolocation 3.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/.npmignore +4 -0
- package/CHANGELOG.md +290 -0
- package/CLAUDE.md +56 -0
- package/HISTORY.md +125 -0
- package/README.md +189 -4
- package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +90 -0
- package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +310 -1
- package/android/common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +127 -0
- package/android/common/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +27 -11
- package/android/common/src/main/java/com/marianhello/bgloc/Config.java +268 -0
- package/android/common/src/main/java/com/marianhello/bgloc/HttpPostService.java +86 -26
- package/android/common/src/main/java/com/marianhello/bgloc/PluginDelegate.java +26 -0
- package/android/common/src/main/java/com/marianhello/bgloc/PostLocationTask.java +42 -5
- package/android/common/src/main/java/com/marianhello/bgloc/driving/DrivingEventsDetector.java +265 -0
- package/android/common/src/main/java/com/marianhello/bgloc/http/UrlTemplateResolver.java +115 -0
- package/android/common/src/main/java/com/marianhello/bgloc/oem/BatteryOemHelper.java +214 -0
- package/android/common/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +13 -9
- package/android/common/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +29 -40
- package/android/common/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +14 -34
- package/android/common/src/main/java/com/marianhello/bgloc/sensor/SensorFusionDetector.java +199 -0
- package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +305 -6
- package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +14 -2
- package/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +50 -3
- package/android/dependencies.gradle +0 -3
- package/angular/background-geolocation-events.ts +21 -0
- package/angular/background-geolocation.service.ts +63 -0
- package/angular/dist/background-geolocation-events.d.ts +18 -1
- package/angular/dist/background-geolocation.service.d.ts +36 -0
- package/angular/dist/esm2022/background-geolocation-events.mjs +22 -1
- package/angular/dist/esm2022/background-geolocation.service.mjs +35 -1
- package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs +55 -0
- package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs.map +1 -1
- package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +312 -1
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +22 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +400 -15
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +12 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +83 -5
- package/ios/common/BackgroundGeolocation/MAURConfig.h +15 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.m +100 -3
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +29 -2
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +4 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +97 -44
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.h +41 -0
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.m +137 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.h +31 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.m +107 -0
- package/package.json +41 -1
- package/plugin.xml +19 -8
- package/www/BackgroundGeolocation.d.ts +517 -3
- package/www/BackgroundGeolocation.js +54 -1
- package/RELEASE.MD +0 -16
package/.npmignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,295 @@
|
|
|
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
|
+
|
|
9
|
+
## [4.2.0](https://github.com/josuelmm/cordova-background-geolocation/tree/4.2.0) (2026-05-08)
|
|
10
|
+
|
|
11
|
+
### Phase 8 — Real sensor fusion (accelerometer + gyroscope)
|
|
12
|
+
|
|
13
|
+
#### Added
|
|
14
|
+
- Android `SensorFusionDetector` (`Sensor.TYPE_LINEAR_ACCELERATION` + `Sensor.TYPE_GYROSCOPE`, `SENSOR_DELAY_GAME`).
|
|
15
|
+
- iOS `MAURSensorFusionDetector` (`CMMotionManager.startDeviceMotionUpdatesToQueue`, 50 Hz).
|
|
16
|
+
- `drivingEvents.sensorFusion` flag (off by default) plus `crashImpactG`, `sensorCrashCooldownMs`, `phoneUsageWindowMs`, `phoneUsageCooldownMs` thresholds.
|
|
17
|
+
- `possibleCrash` event payload now carries `source: "gps" | "sensor"` so consumers can distinguish the GPS heuristic from the accelerometer impact.
|
|
18
|
+
- New event `phoneUsageWhileDriving`: detects sustained device interaction (gyro/accel jitter) while a trip is active and the screen is on.
|
|
19
|
+
- Hot-reload: `configure()` reevaluates and (re)starts sensor pipeline on both platforms.
|
|
20
|
+
|
|
21
|
+
#### Notes
|
|
22
|
+
- Sensor pipeline only samples while `tripActive` is true → modest battery cost.
|
|
23
|
+
- Android requires `TYPE_LINEAR_ACCELERATION` (gravity-removed); fallback path skips silently if unavailable.
|
|
24
|
+
- iOS uses foreground-active heuristic for screen-on (background = passenger usage assumed).
|
|
25
|
+
|
|
26
|
+
## [4.1.0](https://github.com/josuelmm/cordova-background-geolocation/tree/4.1.0) (2026-05-09)
|
|
27
|
+
|
|
28
|
+
### Phase 6.1 — GPS-derived sensor-like driving events
|
|
29
|
+
|
|
30
|
+
#### Added
|
|
31
|
+
|
|
32
|
+
- **`hardBrake`** — emitted when GPS-derived deceleration `Δspeed/Δt` ≤ `-drivingEvents.hardBrakeMps2` during an active trip. Payload `{ location, value }` where `value` is the negative m/s².
|
|
33
|
+
- **`rapidAcceleration`** — emitted when GPS-derived acceleration ≥ `drivingEvents.rapidAccelMps2` during an active trip.
|
|
34
|
+
- **`sharpTurn`** — emitted when |Δbearing|/Δt ≥ `drivingEvents.sharpTurnDegPerSec` and speed ≥ 5 m/s (filters GPS jitter at low speeds).
|
|
35
|
+
- **`possibleCrash`** — heuristic. Fires when speed drops by ≥ `drivingEvents.crashImpactKmh` within `crashWindowMs` and ends near 0 during an active trip. Payload `{ location, value }` where `value` is the velocity drop in km/h. **Apps must always confirm with the user before notifying contacts** — false positives are expected (sudden tunnel exit, GPS glitches).
|
|
36
|
+
- All 4 events have a 4-second cooldown to avoid refiring during sustained events.
|
|
37
|
+
|
|
38
|
+
#### Added — Config
|
|
39
|
+
|
|
40
|
+
- Extended `drivingEvents` with: `hardBrakeMps2` (default 3.5), `rapidAccelMps2` (default 3.5), `sharpTurnDegPerSec` (default 30), `crashImpactKmh` (default 25), `crashWindowMs` (default 2000). Set any to `0` to disable that specific event.
|
|
41
|
+
|
|
42
|
+
#### Implementation
|
|
43
|
+
|
|
44
|
+
- Android `DrivingEventsDetector`: state machine extended with `prevSpeed`/`prevBearing` deltas, per-event cooldown, and the 4 new listener callbacks.
|
|
45
|
+
- Android `Config.DrivingEventsOptions`: 5 new fields parceled with the existing primitives pattern.
|
|
46
|
+
- Android `LocationServiceImpl`: 4 new MSG codes (120-123) routed through `BackgroundGeolocationFacade` to the new default-no-op methods on `PluginDelegate`.
|
|
47
|
+
- iOS `MAURBackgroundGeolocationFacade.drivingDetectorFeed:`: same state machine in Objective-C, posting 4 new `NSNotification` names.
|
|
48
|
+
- iOS `CDVBackgroundGeolocation`: 4 new observers + `sendDrivingEventN:note:` helper.
|
|
49
|
+
- TypeScript: 4 new event names in `Event` union and `BackgroundGeolocationEvents` enum; 4 new typed `on()` overloads.
|
|
50
|
+
- Plugin version bumped to `4.1.0` in all 4 sync points.
|
|
51
|
+
|
|
52
|
+
#### Sensor-fusion (deferred)
|
|
53
|
+
|
|
54
|
+
- Real accelerometer + gyroscope sampling (`Sensor.TYPE_LINEAR_ACCELERATION`, `CMMotionManager.deviceMotion`) deferred. The current heuristics work surprisingly well for `hardBrake` and `rapidAcceleration` because GPS already reports speed; `sharpTurn` works above 5 m/s; `possibleCrash` is intentionally conservative. v4.2 will add a separate `SensorFusionDetector` for finer-grained event detection during slow driving and parking-lot crashes.
|
|
55
|
+
|
|
56
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/4.0.0...4.1.0)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## [4.0.0](https://github.com/josuelmm/cordova-background-geolocation/tree/4.0.0) (2026-05-08)
|
|
61
|
+
|
|
62
|
+
### Phase 6 — Driver insights (Roadmap v4.0)
|
|
63
|
+
|
|
64
|
+
#### Added — GPS-based driver-insight events (no extra sensors required)
|
|
65
|
+
|
|
66
|
+
- **`tripStart`** — emitted when the user moves continuously above `drivingEvents.minTripSpeed` for `minTripDuration`. Payload: latest location.
|
|
67
|
+
- **`tripEnd`** — emitted when the user becomes "stopped" while a trip was active. Payload: `{ location, distance, durationMs }`.
|
|
68
|
+
- **`moving`** — speed crossed above `minMovingSpeed`.
|
|
69
|
+
- **`stopped`** — speed below the threshold for `stoppedDuration`.
|
|
70
|
+
- **`speeding`** — speed crossed above `drivingEvents.speedLimit` (km/h). Rearms when speed drops below.
|
|
71
|
+
- **`providerChange`** — native location provider changed (GPS / network / fused). Payload: `{ provider }`.
|
|
72
|
+
- **`sos`** — emitted by `BackgroundGeolocation.triggerSOS(payload?)`. Payload: user dictionary plus `location` (the latest known fix; absent if no fix yet).
|
|
73
|
+
|
|
74
|
+
#### Added — Methods
|
|
75
|
+
|
|
76
|
+
- **`triggerSOS(payload?)`** — JS API + Angular service + Android `BackgroundGeolocationFacade.triggerSOS(JSONObject)` + iOS `MAURBackgroundGeolocationFacade triggerSOS:`.
|
|
77
|
+
|
|
78
|
+
#### Added — Config
|
|
79
|
+
|
|
80
|
+
- **`drivingEvents`** option:
|
|
81
|
+
```ts
|
|
82
|
+
drivingEvents?: {
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
speedLimit?: number; // km/h, 0 disables
|
|
85
|
+
minMovingSpeed?: number; // m/s, default 1.0
|
|
86
|
+
stoppedDuration?: number; // ms, default 60000
|
|
87
|
+
minTripSpeed?: number; // m/s, default 3.0
|
|
88
|
+
minTripDuration?: number; // ms, default 30000
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Implementation
|
|
93
|
+
|
|
94
|
+
- New shared GPS state machine: Android `com.marianhello.bgloc.driving.DrivingEventsDetector` (pure-Java, hosted by `LocationServiceImpl.onLocation` and broadcasting via the `MSG_ON_*` pipeline); iOS inline detector inside `MAURBackgroundGeolocationFacade` posting `NSNotification`s.
|
|
95
|
+
- New Android MSG codes: `MSG_ON_TRIP_START` (113), `MSG_ON_TRIP_END` (114), `MSG_ON_MOVING` (115), `MSG_ON_STOPPED` (116), `MSG_ON_SPEEDING` (117), `MSG_ON_PROVIDER_CHANGE` (118), `MSG_ON_SOS` (119). Routed by `BackgroundGeolocationFacade` to the new default-no-op methods on `PluginDelegate`.
|
|
96
|
+
- iOS notification names: `MAURTripStartNotification`, `MAURTripEndNotification`, `MAURMovingNotification`, `MAURStoppedNotification`, `MAURSpeedingNotification`, `MAURProviderChangeNotification`, `MAURSOSNotification`. Observed by `CDVBackgroundGeolocation.pluginInitialize`.
|
|
97
|
+
- TypeScript: 7 new event names in the `Event` union and `BackgroundGeolocationEvents` enum; 7 new typed `on()` overloads with full payload typings; new `triggerSOS()` method declaration.
|
|
98
|
+
- Plugin version bumped to `4.0.0` in `package.json`, `plugin.xml`, Android `PLUGIN_VERSION` and iOS `getPluginVersion`.
|
|
99
|
+
|
|
100
|
+
#### Sensor-fusion events deferred to v4.1
|
|
101
|
+
|
|
102
|
+
- `hardBrake`, `rapidAcceleration`, `sharpTurn`, `possibleCrash` require accelerometer + gyroscope sampling and a separate detector class. They are intentionally not part of v4.0.0 to keep this release focused on GPS-only signals that work reliably on every device. The API surface for `drivingEvents` is intentionally extensible so v4.1 can add `hardBrakeMps2`, `sharpTurnDegPerSec`, `crashImpactKmh` thresholds without breaking changes.
|
|
103
|
+
|
|
104
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/3.6.0...4.0.0)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## [3.6.0](https://github.com/josuelmm/cordova-background-geolocation/tree/3.6.0) (2026-05-08)
|
|
109
|
+
|
|
110
|
+
### Phase 5 — Battery / OEM helpers (Roadmap v3.6)
|
|
111
|
+
|
|
112
|
+
#### Added
|
|
113
|
+
|
|
114
|
+
- **`isIgnoringBatteryOptimizations()`** — Android: returns `true` if the app is on the system battery-optimisation whitelist (Settings → Battery → "Don't optimise"). iOS: resolves `true` (concept does not apply).
|
|
115
|
+
- **`requestIgnoreBatteryOptimizations()`** — Android: opens the system dialog to add the app to the whitelist; the user must accept. Falls back to the battery settings screen if the system dialog is unavailable. iOS: no-op resolves `true`.
|
|
116
|
+
- **`openBatterySettings()`** — Android: opens the per-app battery-optimisation settings screen (with fallback to app-info). iOS: opens the app's Settings entry via `UIApplicationOpenSettingsURLString`.
|
|
117
|
+
- **`openAutoStartSettings()`** — Android: opens the OEM-specific "auto-start" / "background activity" screen on Xiaomi MIUI, Huawei EMUI, Oppo ColorOS, Vivo FunTouch, OnePlus, Asus and Samsung (Samsung falls back to app-info because there is no stable component). Resolves `{ opened, manufacturer, screen }`. iOS: opens the app's Settings entry and reports `manufacturer: 'apple'`.
|
|
118
|
+
- **`getManufacturerHelp()`** — returns OEM-specific guidance steps (`{ manufacturer, steps: string[] }`) so the app can render an actionable help screen when the FGS is being killed by the OEM. Coverage: Xiaomi (MIUI/Redmi/Poco), Huawei/Honor (EMUI), Oppo (ColorOS), Vivo (FunTouch), Samsung (One UI), OnePlus, Asus, generic Android, iOS.
|
|
119
|
+
|
|
120
|
+
#### Implementation
|
|
121
|
+
|
|
122
|
+
- New helper class `com.marianhello.bgloc.oem.BatteryOemHelper` (Android) wraps the `PowerManager.isIgnoringBatteryOptimizations(...)` call, the `Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS` dialog, and a per-OEM `ComponentName` table for the auto-start screens. Components verified against AOSP / OEM forks.
|
|
123
|
+
- iOS: 5 best-effort selectors in `CDVBackgroundGeolocation.m` that use `UIApplicationOpenSettingsURLString` and report `manufacturer: 'apple'` so the JS layer can branch with `getManufacturerHelp()`.
|
|
124
|
+
- TypeScript surface: 5 new methods on the `BackgroundGeolocationPlugin` interface with strong types for the result objects (`isIgnoringBatteryOptimizations`, `requestIgnoreBatteryOptimizations`, `openBatterySettings`, `openAutoStartSettings`, `getManufacturerHelp`).
|
|
125
|
+
- Angular service re-exports all 5 methods.
|
|
126
|
+
- `plugin.xml`: registers `android/common/.../oem/BatteryOemHelper.java` as a `<source-file>`.
|
|
127
|
+
- Plugin version bumped to `3.6.0` in `package.json`, `plugin.xml`, Android `PLUGIN_VERSION`, and iOS `getPluginVersion`.
|
|
128
|
+
|
|
129
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/3.5.0...3.6.0)
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## [3.5.0](https://github.com/josuelmm/cordova-background-geolocation/tree/3.5.0) (2026-05-08)
|
|
134
|
+
|
|
135
|
+
### Phase 4 — Diagnostics (Roadmap v3.5)
|
|
136
|
+
|
|
137
|
+
#### Added
|
|
138
|
+
|
|
139
|
+
- **`getDiagnostics()`** — extended diagnostics method that explains *why* tracking may not be running in production. Returns a typed `Diagnostics` object covering, where applicable to the platform: `isRunning`, `locationServicesEnabled`, `startOnBoot`, `pendingSyncCount`, `lastLocationAt`, plus permissions (`fineLocationGranted`, `coarseLocationGranted`, `backgroundLocationGranted`, `notificationPermissionGranted`, `activityRecognitionGranted`), `batteryOptimizationIgnored`, `manufacturer`, `foregroundServiceType` (Android), and `preciseLocationEnabled`, `backgroundRefreshStatus`, `lowPowerModeEnabled`, `motionPermissionStatus`, `authorizationStatusText` (iOS).
|
|
140
|
+
- **`Diagnostics` TypeScript interface** in `www/BackgroundGeolocation.d.ts`.
|
|
141
|
+
- **Angular service:** `BackgroundGeolocationService.getDiagnostics(success?, fail?)`.
|
|
142
|
+
|
|
143
|
+
#### Implementation
|
|
144
|
+
|
|
145
|
+
- Android `BackgroundGeolocationPlugin`: new action `getDiagnostics` + helpers `hasPermission`, `isIgnoringBatteryOptimizations`, `readForegroundServiceTypeFromManifest`. Plugin version bumped to `3.5.0`.
|
|
146
|
+
- iOS `CDVBackgroundGeolocation`: new selector `getDiagnostics:` reads `CLLocationManager.authorizationStatus`, `accuracyAuthorization` (iOS 14+), `UIBackgroundRefreshStatus`, `NSProcessInfo.lowPowerModeEnabled` (iOS 9+), `CMMotionActivityManager.authorizationStatus` (iOS 11+), and `MAURSQLiteLocationDAO.getLocationsForSyncCount`.
|
|
147
|
+
- New imports added to iOS plugin: `CoreMotion/CoreMotion.h`, `UIKit/UIKit.h`, `MAURSQLiteLocationDAO.h`.
|
|
148
|
+
|
|
149
|
+
### Phase 4 — extra (still in 3.5.0)
|
|
150
|
+
|
|
151
|
+
- **`mockLocationPolicy: 'allow' | 'flag' | 'drop'`** — applied in Android `PostLocationTask` and iOS `MAURPostLocationTask`. With `'drop'`, a mocked location is discarded before persisting/posting; with `'flag'` it is delivered but the existing `isFromMockProvider` (Android) / `simulated` (iOS) field marks it; `'allow'` (default) preserves current behaviour.
|
|
152
|
+
- **`heartbeatInterval`** config option added to `Config` / `MAURConfig` and `.d.ts`. Native timer-based emission of `heartbeat` is **still deferred** to 3.5.1+ (the surface — config + event name — is registered).
|
|
153
|
+
- **Sync events emission (real, native).**
|
|
154
|
+
- Android: `MSG_ON_SYNC_START`, `MSG_ON_SYNC_SUCCESS`, `MSG_ON_SYNC_ERROR` codes added to `LocationServiceImpl`. `PluginDelegate` extended with default-no-op `onSyncStart()`, `onSyncSuccess(int)`, `onSyncError(int, String)`. `BackgroundGeolocationFacade.serviceBroadcastReceiver` routes them to the delegate. `SyncAdapter.uploadLocations` broadcasts `MSG_ON_SYNC_START` before the upload, then `MSG_ON_SYNC_SUCCESS` (with `sent` count) on 2xx or `MSG_ON_SYNC_ERROR` (with `httpStatus` + message) on non-2xx / IOException. `BackgroundGeolocationPlugin` overrides the new delegate methods and emits the events to JS.
|
|
155
|
+
- iOS: new notification names `MAURBackgroundSyncDidStartNotification`, `MAURBackgroundSyncDidSucceedNotification`, `MAURBackgroundSyncDidFailNotification` posted from `MAURBackgroundSync`. `CDVBackgroundGeolocation` registers observers in `pluginInitialize` and forwards them as `syncStart` / `syncSuccess` / `syncError` JS events. Payload includes `sent` (success) and `httpStatus` + `message` (error). `MAURBackgroundSyncDelegate` also exposes the new optional methods for in-process listeners.
|
|
156
|
+
- TypeScript: `Event` union extended with `'heartbeat' | 'syncStart' | 'syncProgress' | 'syncSuccess' | 'syncError'` so `removeAllListeners('syncSuccess')` etc. type-check.
|
|
157
|
+
|
|
158
|
+
### Bug fixes
|
|
159
|
+
|
|
160
|
+
- **iOS `getPluginVersion`:** returned the hardcoded string `"3.2.0"`; now returns `"3.5.0"` matching `plugin.xml` and the Android `PLUGIN_VERSION`. Production traceability restored.
|
|
161
|
+
|
|
162
|
+
### Phase 4 — additional fixes (still in 3.5.0)
|
|
163
|
+
|
|
164
|
+
- **`syncProgress` now emits natively.** Android: `MSG_ON_SYNC_PROGRESS = 111` added to `LocationServiceImpl`; `SyncAdapter.onProgress(int)` broadcasts the percentage; `BackgroundGeolocationFacade` routes it to the new `PluginDelegate.onSyncProgress(int)` (default no-op); `BackgroundGeolocationPlugin` emits the JS event with the integer payload. iOS: `NSURLSessionTaskDelegate didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` computes 0..100 and posts `MAURBackgroundSyncDidProgressNotification`; `CDVBackgroundGeolocation` forwards it as `syncProgress` JS event with numeric payload.
|
|
165
|
+
- **TypeScript `on()` overloads** for the new events: `'heartbeat'`, `'syncStart'`, `'syncProgress'`, `'syncSuccess'`, `'syncError'`. Apps can now write `BackgroundGeolocation.on('syncSuccess', ({ sent }) => ...)` with full type safety. The catch-all `BackgroundGeolocationEvents` enum overload was widened to cover the new payload shapes.
|
|
166
|
+
- **Bug: `MAURBackgroundSync` `tasks` was never allocated** — `addObject:`, `removeObject:`, `cancel` and `status` silently no-op'd on a `nil` array (Objective-C messages-to-nil semantics), so background uploads couldn't be tracked or cancelled. `tasks` is now `[[NSMutableArray alloc] init]` in `init`.
|
|
167
|
+
|
|
168
|
+
### Phase 4 — heartbeat native emission (still in 3.5.0)
|
|
169
|
+
|
|
170
|
+
- **Heartbeat now emits natively.**
|
|
171
|
+
- Android: `LocationServiceImpl` adds `MSG_ON_HEARTBEAT = 112`, a `mLastReceivedLocation` field updated on every `onLocation()`, and a `ScheduledExecutorService`-based scheduler started after `MSG_ON_SERVICE_STARTED` and cancelled on stop. Each tick broadcasts the latest `BackgroundLocation` as the `payload` parcelable. `BackgroundGeolocationFacade` routes `MSG_ON_HEARTBEAT` to the new `PluginDelegate.onHeartbeat(BackgroundLocation)` (default no-op). `BackgroundGeolocationPlugin` forwards it to JS as `sendEvent("heartbeat", location.toJSONObjectWithId())`.
|
|
172
|
+
- iOS: `MAURBackgroundGeolocationFacade` declares `MAURHeartbeatNotification`, caches `lastReceivedLocation` on every `onLocationChanged:`, schedules an `NSTimer` (main run loop) when `start:` succeeds and invalidates it in `stop:`. Each tick posts `MAURHeartbeatNotification` with `userInfo[@"location"]`. `CDVBackgroundGeolocation` observes and emits a `heartbeat` JS event with the location dictionary (or empty when no fix yet).
|
|
173
|
+
|
|
174
|
+
### Status
|
|
175
|
+
|
|
176
|
+
- All Phase 4 deliverables for 3.5.0 are now native and end-to-end:
|
|
177
|
+
- `getDiagnostics()` ✅
|
|
178
|
+
- `mockLocationPolicy` ✅
|
|
179
|
+
- `syncStart` / `syncProgress` / `syncSuccess` / `syncError` ✅
|
|
180
|
+
- `heartbeat` ✅
|
|
181
|
+
|
|
182
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/3.4.0...3.5.0)
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## [3.4.0](https://github.com/josuelmm/cordova-background-geolocation/tree/3.4.0) (2026-05-08)
|
|
187
|
+
|
|
188
|
+
### Phase 3 — Location API modernization (Roadmap v3.4)
|
|
189
|
+
|
|
190
|
+
#### Android
|
|
191
|
+
|
|
192
|
+
- **`ActivityRecognitionLocationProvider.java`:** migrated to `new LocationRequest.Builder(priority, intervalMillis)` + `Priority.PRIORITY_*` (from `com.google.android.gms.location.Priority`). Replaces `LocationRequest.create()`, `setPriority()`, `setInterval()`, `setFastestInterval()` and `LocationRequest.PRIORITY_*` — all deprecated since `play-services-location 21.0.0`. Adds `setMinUpdateIntervalMillis` (replaces `fastestInterval`) and `setWaitForAccurateLocation(false)`.
|
|
193
|
+
- **`RawLocationProvider.java`:** removed `Criteria` API and `LocationManager.getBestProvider(criteria, true)`. Provider selection is now explicit GPS-first / Network-fallback. Drops the historical "boost stationary" Criteria block; behaviour matches GPS-enabled path on modern Android.
|
|
194
|
+
- **`plugin.xml`:** bumped `GOOGLE_PLAY_SERVICES_VERSION` default from `17+` to `21.0.1`. Apps overriding the variable continue to work.
|
|
195
|
+
|
|
196
|
+
#### iOS
|
|
197
|
+
|
|
198
|
+
- **`MAURPostLocationTask.m`:** migrated `[NSURLConnection sendSynchronousRequest:returningResponse:error:]` (deprecated since iOS 9) to `NSURLSession dataTaskWithRequest:completionHandler:` synchronised via `dispatch_semaphore`. Caller still receives `error` and `statusCode` with the same semantics; the call is safe because it runs on a background queue.
|
|
199
|
+
- **`MAURDistanceFilterLocationProvider.m`:** added `locationManagerDidChangeAuthorization:` (iOS 14+) which is the canonical replacement for the deprecated `locationManager:didChangeAuthorizationStatus:`. Both callbacks share a private helper `handleAuthorizationStatusChange:`. The legacy callback is short-circuited on iOS 14+ to avoid double-notifying delegates.
|
|
200
|
+
- **`MAURDistanceFilterLocationProvider.m` + `MAURConfig`:** new `showsBackgroundLocationIndicator` config option (iOS 11+). When `true`, iOS shows the blue status indicator while the app uses location in the background.
|
|
201
|
+
|
|
202
|
+
#### TypeScript
|
|
203
|
+
|
|
204
|
+
- `www/BackgroundGeolocation.d.ts`: added `showsBackgroundLocationIndicator?: boolean` (iOS) with documentation.
|
|
205
|
+
|
|
206
|
+
#### Versions
|
|
207
|
+
|
|
208
|
+
- `cordovaDependencies."3.4.0"`: requires `cordova-ios >= 6.2.0`. The new APIs use runtime availability checks (`@available(iOS 11.0, *)` for `showsBackgroundLocationIndicator`, `API_AVAILABLE(ios(14.0))` for `locationManagerDidChangeAuthorization:`), so older iOS versions still link and run.
|
|
209
|
+
|
|
210
|
+
### Bug fixes
|
|
211
|
+
|
|
212
|
+
- **iOS `MAURConfig.fromDictionary`:** corrected `isNull(config[@"activitiesInterval"])` → `isNotNull(...)`. The inverted check meant a value sent by the app was assigned only when the dictionary entry was missing/null, effectively dropping user input. Pre-existing bug.
|
|
213
|
+
- **Android `HttpPostService.postJSONString`:** `Content-Length` now uses UTF-8 byte length instead of `String.length()`. Multi-byte characters (`ñ`, `é`, emoji, ...) now match the body sent. Pre-existing bug.
|
|
214
|
+
|
|
215
|
+
### Phase 3 also closed
|
|
216
|
+
|
|
217
|
+
- **Android `DistanceFilterLocationProvider`:** the legacy `Criteria` API is fully removed. The `criteria` field, its init in `onCreate()`, and the `translateDesiredAccuracy(...)` helper are gone. `LocationManager.getBestProvider(criteria, true)` is replaced by an explicit `pickProvider()` (GPS-first, Network-fallback). `requestSingleUpdate(criteria, ...)` in `StationaryLocationMonitorReceiver` is replaced by the provider-string overload plus a wider `try/catch` that also handles `IllegalArgumentException`.
|
|
218
|
+
|
|
219
|
+
### Notes (still legacy but functional)
|
|
220
|
+
|
|
221
|
+
- `LocationManager.getLastKnownLocation(provider)` is **not** deprecated; only `getBestProvider(Criteria, ...)` is. Kept as-is in `getLastBestLocation()`.
|
|
222
|
+
- `LocationManager.requestSingleUpdate(String, PendingIntent)` is deprecated since API 30 but is the only PendingIntent-based path; the modern `getCurrentLocation` does not accept a `PendingIntent` and would require redesigning the receiver pattern that wakes the app from background.
|
|
223
|
+
- `AlarmManager.setInexactRepeating` retained for stationary polling. Doze defers it to ≥9-15 min windows; an FGS-driven `LocationCallback` interval is the planned replacement.
|
|
224
|
+
|
|
225
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/3.3.0...3.4.0)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## [3.3.0](https://github.com/josuelmm/cordova-background-geolocation/tree/3.3.0) (2026-05-07)
|
|
230
|
+
|
|
231
|
+
### Phase 2 — Backend-agnostic HTTP transport (Roadmap v3.3)
|
|
232
|
+
|
|
233
|
+
#### Added
|
|
234
|
+
|
|
235
|
+
- **`httpMethod`** and **`syncHttpMethod`** config options. Values: `POST` (default), `GET`, `PUT`, `PATCH`. Removes the previously hardcoded `POST` in Android (`HttpPostService.java`) and iOS (`MAURPostLocationTask.m`, `MAURBackgroundSync.m`).
|
|
236
|
+
- **`httpMode`** and **`syncMode`** config options. Values: `batch` (default) or `single` (one HTTP request per location). `single` is required when `httpMethod === 'GET'`.
|
|
237
|
+
- **URL templating.** The plugin now substitutes placeholders in `url`, `syncUrl` (and string values inside `bodyTemplate`/`postTemplate`) using the current location plus any `queryParams`. Built-in placeholders: `{latitude}`, `{longitude}`, `{lat}`, `{lon}`, `{time}`, `{timestamp}`, `{timestamp_iso}`, `{speed}`, `{altitude}`, `{bearing}`, `{accuracy}`, `{provider}`. Any extra `queryParams` keys are also available (e.g. `{device_id}`, `{token}`).
|
|
238
|
+
- **`queryParams`** config option. Static dictionary used to fill placeholders not derived from a location.
|
|
239
|
+
- **`headers`** config option as alias of `httpHeaders` (if both are present, `headers` wins).
|
|
240
|
+
- **`bodyTemplate`** config option as alias of `postTemplate`.
|
|
241
|
+
- New helpers: Android `com.marianhello.bgloc.http.UrlTemplateResolver` and iOS `MAURUrlTemplateResolver`.
|
|
242
|
+
|
|
243
|
+
#### Changed
|
|
244
|
+
|
|
245
|
+
- **`Config` / `MAURConfig`** extended with the new transport options. Parcelable read/write, copy constructor, defaults, `merge`, `toString`, `toDictionary` and `ConfigMapper` updated accordingly. All existing apps using only `url` + `httpHeaders` + `postTemplate` continue to work unchanged.
|
|
246
|
+
- **`HttpPostService`** Android: `setRequestMethod` is now driven by the configured method. GET requests skip the body entirely. New static helpers `postJSON(url, json, headers, method)` and `postJSONFile(url, file, headers, listener, method)`.
|
|
247
|
+
- **`MAURPostLocationTask` / `MAURBackgroundSync`** iOS: `setHTTPMethod` is parameterised. URL templates are resolved before each request. `single` mode posts one location per request.
|
|
248
|
+
|
|
249
|
+
### Phase 1 — Auto-start Android (Roadmap v3.3)
|
|
250
|
+
|
|
251
|
+
#### Added
|
|
252
|
+
|
|
253
|
+
- **Android `ACCESS_BACKGROUND_LOCATION` permission** declared in `plugin.xml`. Required for Android 10+ when starting the foreground location service from background (boot, app update). Apps must request it at runtime with the proper flow (foreground → explanation → "Allow all the time").
|
|
254
|
+
- **Boot/replace receiver expanded.** `BootCompletedReceiver` now also handles:
|
|
255
|
+
- `android.intent.action.QUICKBOOT_POWERON` (HTC, MIUI / Xiaomi).
|
|
256
|
+
- `com.htc.intent.action.QUICKBOOT_POWERON`.
|
|
257
|
+
- `android.intent.action.MY_PACKAGE_REPLACED` — service is restarted after the app is updated via Play Store, with no need for the user to re-open the app.
|
|
258
|
+
- **Background location permission validated** in `BootCompletedReceiver` (Android 10+ only) and in `LocationServiceProxy.startForegroundService()`.
|
|
259
|
+
- **`ForegroundServiceStartNotAllowedException` handled** (Android 12+). Both `BootCompletedReceiver` and `LocationServiceProxy.startForegroundService()` now wrap `startForegroundService()` in try/catch with clear logging. WorkManager is **not** used as a fallback for tracking — it is only suitable for deferred sync, not for continuous GPS.
|
|
260
|
+
|
|
261
|
+
#### Changed
|
|
262
|
+
|
|
263
|
+
- **`foregroundServiceType` simplified to `"location"`** (was `"location|dataSync"`). The service does not perform `dataSync`; declaring it added unnecessary scrutiny in Play Console.
|
|
264
|
+
- **`LocationServiceImpl.startForeground()`** now reads `foregroundServiceType` dynamically from the merged manifest via `getManifestForegroundServiceType()` instead of using a hardcoded `0x8`. If the manifest type cannot be read (returns 0), the service refuses to start in foreground and logs an error rather than calling `startForeground` with an invalid type.
|
|
265
|
+
- **`LocationServiceProxy.startForegroundService()`** no longer falls back to a non-foreground `startService()` when the location permission is missing. It now logs and exits, avoiding zombie services.
|
|
266
|
+
- **`engines`** raised in both `package.json` and `plugin.xml`: `cordova >= 10.0.0`, `cordova-android >= 12.0.0`. Required for `targetSdk 34+` and modern foreground service handling.
|
|
267
|
+
|
|
268
|
+
#### Removed
|
|
269
|
+
|
|
270
|
+
- **`FOREGROUND_SERVICE_DATA_SYNC` permission** removed from `plugin.xml`. Pair of the `dataSync` foreground type cleanup above.
|
|
271
|
+
- **`<uses-library android:name="org.apache.http.legacy" />`** removed from `plugin.xml`. The plugin's HTTP client uses `HttpURLConnection`; no `org.apache.http.*` imports exist in the codebase.
|
|
272
|
+
- **`useLibrary 'org.apache.http.legacy'`** removed from `android/dependencies.gradle`. Same reason.
|
|
273
|
+
- **Dead constant `FOREGROUND_SERVICE_TYPE_LOCATION = 4`** removed from `LocationServiceImpl.java`. Its value was incorrect (real value is `0x00000008 = 8`; `4` is `PHONE_CALL`) and the constant was never referenced.
|
|
274
|
+
|
|
275
|
+
#### Build
|
|
276
|
+
|
|
277
|
+
- **`jcenter()` replaced with `mavenCentral()`** in `android/build.gradle` (both `buildscript` and `allprojects` blocks). JCenter has been deprecated since 2022.
|
|
278
|
+
|
|
279
|
+
#### Documentation
|
|
280
|
+
|
|
281
|
+
- **`docs/auto-start.md`** — full guide for boot/restart behavior (Android current state, gaps, v3.3 plan with concrete diffs; iOS limitations).
|
|
282
|
+
- **`docs/http-transport.md`** — backend-agnostic HTTP transport (Phase 2, v3.3.0).
|
|
283
|
+
- **`docs/traccar.md`** — Traccar as an optional backend example (geofences, events, history); plugin remains backend-agnostic.
|
|
284
|
+
- **`docs/driving-events.md`** — driving events plan (Phase 6, v4.0).
|
|
285
|
+
- **`docs/location-modernization.md`** — location API modernization plan (Phase 3, v3.4).
|
|
286
|
+
- **`docs/ROADMAP.md`** — phases 1→6.
|
|
287
|
+
- **`REVIEW_3.2.0.md`** — full audit and rationale for the roadmap.
|
|
288
|
+
|
|
289
|
+
[Full Changelog](https://github.com/josuelmm/cordova-background-geolocation/compare/3.2.0...3.3.0)
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
3
293
|
## [3.2.0](https://github.com/josuelmm/cordova-background-geolocation/tree/3.2.0) (2026-02-28)
|
|
4
294
|
|
|
5
295
|
### Added
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Global Instructions
|
|
2
|
+
|
|
3
|
+
## Ejecución
|
|
4
|
+
Pensar antes de actuar.
|
|
5
|
+
Ejecutar herramienta primero.
|
|
6
|
+
Leer archivos existentes antes de escribir código.
|
|
7
|
+
Abrir solo archivos relevantes.
|
|
8
|
+
Usar rg antes de abrir muchos archivos.
|
|
9
|
+
No releer archivos ya leídos, salvo cambio posible.
|
|
10
|
+
Leer por rangos, no completo.
|
|
11
|
+
Omitir archivos mayores de 100 KB, salvo necesidad explícita.
|
|
12
|
+
Ignorar vendor, node_modules, dist, build, storage/logs y binarios.
|
|
13
|
+
Preferir editar antes que reescribir completo.
|
|
14
|
+
Hacer diffs mínimos.
|
|
15
|
+
No tocar código no relacionado.
|
|
16
|
+
No refactorizar sin pedirlo.
|
|
17
|
+
No cambiar arquitectura sin permiso.
|
|
18
|
+
Preguntar antes de instalar paquetes.
|
|
19
|
+
Preguntar antes de borrar archivos.
|
|
20
|
+
Preguntar antes de migraciones destructivas.
|
|
21
|
+
|
|
22
|
+
## Validación
|
|
23
|
+
Probar código antes de darlo por terminado.
|
|
24
|
+
Validar con comando específico.
|
|
25
|
+
No ejecutar tests pesados sin pedirlo.
|
|
26
|
+
Reportar solo errores reales.
|
|
27
|
+
Ejecutar /cost en sesiones largas.
|
|
28
|
+
Iniciar nueva sesión si tarea cambia.
|
|
29
|
+
|
|
30
|
+
## Respuesta
|
|
31
|
+
Mostrar resultado y parar.
|
|
32
|
+
Salida concisa.
|
|
33
|
+
Razonamiento exhaustivo interno.
|
|
34
|
+
Cero relleno.
|
|
35
|
+
Sin introducciones aduladoras.
|
|
36
|
+
Sin cierres superfluos.
|
|
37
|
+
Frases de 3 a 6 palabras.
|
|
38
|
+
Sin artículos innecesarios.
|
|
39
|
+
Solo bugs y cambios.
|
|
40
|
+
Sin explicación extra.
|
|
41
|
+
No repetir input.
|
|
42
|
+
Respetar formato definido.
|
|
43
|
+
No asumir datos.
|
|
44
|
+
Preguntar solo si hay bloqueo real.
|
|
45
|
+
Reportar solo archivos modificados.
|
|
46
|
+
|
|
47
|
+
## Formato por defecto
|
|
48
|
+
Cambios:
|
|
49
|
+
- archivo: resumen corto
|
|
50
|
+
|
|
51
|
+
Validación:
|
|
52
|
+
- comando ejecutado
|
|
53
|
+
- resultado
|
|
54
|
+
|
|
55
|
+
Pendiente:
|
|
56
|
+
- solo si falta dato
|
package/HISTORY.md
CHANGED
|
@@ -2,6 +2,131 @@
|
|
|
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
|
+
|
|
12
|
+
## [4.2.0] - 2026-05-08
|
|
13
|
+
|
|
14
|
+
### Phase 8 — Real sensor fusion (accelerometer + gyroscope)
|
|
15
|
+
|
|
16
|
+
- New Android `com.marianhello.bgloc.sensor.SensorFusionDetector` using `Sensor.TYPE_LINEAR_ACCELERATION` + `Sensor.TYPE_GYROSCOPE` at `SENSOR_DELAY_GAME`.
|
|
17
|
+
- New iOS `MAURSensorFusionDetector` using `CMMotionManager.startDeviceMotionUpdatesToQueue` (50 Hz).
|
|
18
|
+
- New `drivingEvents.sensorFusion` toggle (off by default) plus thresholds: `crashImpactG` (default 3.0), `sensorCrashCooldownMs`, `phoneUsageWindowMs`, `phoneUsageCooldownMs`.
|
|
19
|
+
- `possibleCrash` event payload extended with `source: "gps" | "sensor"`.
|
|
20
|
+
- New `phoneUsageWhileDriving` event (jitter + screen-on during active trip).
|
|
21
|
+
- Hot-reload of sensor pipeline on `configure()`.
|
|
22
|
+
- Plugin version: `4.2.0`.
|
|
23
|
+
|
|
24
|
+
## [4.1.0] - 2026-05-09
|
|
25
|
+
|
|
26
|
+
### Phase 6.1 — GPS-derived sensor-like driving events
|
|
27
|
+
|
|
28
|
+
- New events: `hardBrake`, `rapidAcceleration`, `sharpTurn`, `possibleCrash` (all GPS-derived, no accelerometer/gyroscope yet).
|
|
29
|
+
- New config thresholds: `hardBrakeMps2`, `rapidAccelMps2`, `sharpTurnDegPerSec`, `crashImpactKmh`, `crashWindowMs`. Set any to 0 to disable.
|
|
30
|
+
- 4-second cooldown per event to avoid refiring on sustained conditions.
|
|
31
|
+
- Android `DrivingEventsDetector` extended; iOS detector inline in `MAURBackgroundGeolocationFacade`. Same heuristics on both platforms.
|
|
32
|
+
- 4 new MSG codes (120-123) and 4 new NSNotifications wired end-to-end to JS.
|
|
33
|
+
- Plugin version: `4.1.0`.
|
|
34
|
+
|
|
35
|
+
Sensor fusion (real accelerometer + gyroscope) deferred to v4.2 as a separate `SensorFusionDetector` class.
|
|
36
|
+
|
|
37
|
+
## [4.0.0] - 2026-05-08
|
|
38
|
+
|
|
39
|
+
### Phase 6 — Driver insights (GPS-only)
|
|
40
|
+
|
|
41
|
+
- New events: `tripStart`, `tripEnd` (with `distance` + `durationMs`), `moving`, `stopped`, `speeding`, `providerChange`, `sos`.
|
|
42
|
+
- New method: `triggerSOS(payload?)`. New config: `drivingEvents` with thresholds for moving / trip / speed limit.
|
|
43
|
+
- Shared state machine: Android `DrivingEventsDetector.java` (pure-Java); iOS inline in `MAURBackgroundGeolocationFacade`. Android uses MSG codes 113-119 routed via the existing `PluginDelegate`; iOS uses 7 new `NSNotification`s observed in `CDVBackgroundGeolocation`.
|
|
44
|
+
- TypeScript: 7 new event overloads, new method declaration, new config option.
|
|
45
|
+
- Plugin version: `4.0.0`.
|
|
46
|
+
|
|
47
|
+
### Sensor-fusion events deferred to v4.1
|
|
48
|
+
- `hardBrake`, `rapidAcceleration`, `sharpTurn`, `possibleCrash` require accelerometer + gyroscope. Excluded on purpose to keep v4.0.0 GPS-only and reliable.
|
|
49
|
+
|
|
50
|
+
## [3.6.0] - 2026-05-08
|
|
51
|
+
|
|
52
|
+
### Phase 5 — Battery / OEM helpers
|
|
53
|
+
|
|
54
|
+
- Added `isIgnoringBatteryOptimizations()`, `requestIgnoreBatteryOptimizations()`, `openBatterySettings()`, `openAutoStartSettings()`, `getManufacturerHelp()` (Android + iOS).
|
|
55
|
+
- Android helper class `com.marianhello.bgloc.oem.BatteryOemHelper` with per-OEM `ComponentName` table for auto-start screens (Xiaomi MIUI, Huawei EMUI, Oppo ColorOS, Vivo FunTouch, OnePlus, Asus; Samsung falls back to app-info).
|
|
56
|
+
- iOS uses `UIApplicationOpenSettingsURLString` as best-effort destination and reports `manufacturer: 'apple'`.
|
|
57
|
+
- Angular service re-exports the 5 new helpers with strong types.
|
|
58
|
+
|
|
59
|
+
## [3.5.0] - 2026-05-08
|
|
60
|
+
|
|
61
|
+
### Phase 4 — Diagnostics
|
|
62
|
+
|
|
63
|
+
- Added `getDiagnostics()` (Android + iOS) returning permissions, battery whitelist state, OEM manufacturer, last fix age, pending sync count, foreground service type (Android) and precise location / background refresh / low power / motion permission (iOS).
|
|
64
|
+
- Added `Diagnostics` TypeScript interface in `www/BackgroundGeolocation.d.ts`.
|
|
65
|
+
- Angular service exposes `getDiagnostics()`.
|
|
66
|
+
- Android plugin version bumped to `3.5.0`.
|
|
67
|
+
|
|
68
|
+
- Added `mockLocationPolicy: 'allow' | 'flag' | 'drop'` config (Android `Config` + iOS `MAURConfig`). Applied in `PostLocationTask` (Android) and `MAURPostLocationTask` (iOS): mocked samples are dropped before persistence when policy is `'drop'`.
|
|
69
|
+
- Added `heartbeatInterval` config option (typed in `.d.ts`, persisted in `Config` / `MAURConfig`).
|
|
70
|
+
- Registered events `heartbeat`, `syncStart`, `syncProgress`, `syncSuccess`, `syncError` in `www/BackgroundGeolocation.js` and both `Event` union and `BackgroundGeolocationEvents` enum in `.d.ts`.
|
|
71
|
+
- **Sync events emit natively now**: Android via `MSG_ON_SYNC_*` broadcasts from `SyncAdapter` → `BackgroundGeolocationFacade` → `PluginDelegate` → `BackgroundGeolocationPlugin.sendEvent`; iOS via `NSNotificationCenter` from `MAURBackgroundSync` → `CDVBackgroundGeolocation` observers. `syncSuccess` payload includes `sent`; `syncError` payload includes `httpStatus` + `message`.
|
|
72
|
+
- Bug: iOS `getPluginVersion` returned hardcoded `"3.2.0"`; now `"3.5.0"`.
|
|
73
|
+
|
|
74
|
+
- `syncProgress` emits natively now: Android via `MSG_ON_SYNC_PROGRESS` from `SyncAdapter.onProgress`; iOS via `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` posting `MAURBackgroundSyncDidProgressNotification`. Both are forwarded as `syncProgress` JS events.
|
|
75
|
+
- TypeScript `on()` overloads added for `'heartbeat'`, `'syncStart'`, `'syncProgress'`, `'syncSuccess'`, `'syncError'` so string-literal subscriptions type-check.
|
|
76
|
+
- Bug: iOS `MAURBackgroundSync.tasks` was never allocated. Fixed in `init`.
|
|
77
|
+
|
|
78
|
+
- `heartbeat` emits natively now: Android `LocationServiceImpl` schedules a `ScheduledExecutorService` task on service start using `Config.heartbeatInterval`, broadcasts `MSG_ON_HEARTBEAT` with the latest `BackgroundLocation`, and `BackgroundGeolocationPlugin` forwards it to JS. iOS `MAURBackgroundGeolocationFacade` schedules an `NSTimer` (main run loop), posts `MAURHeartbeatNotification`, and `CDVBackgroundGeolocation` forwards it as a `heartbeat` JS event with the latest location.
|
|
79
|
+
|
|
80
|
+
Phase 4 status: all four deliverables (`getDiagnostics`, `mockLocationPolicy`, sync events, heartbeat) are now native and end-to-end.
|
|
81
|
+
|
|
82
|
+
## [3.4.0] - 2026-05-08
|
|
83
|
+
|
|
84
|
+
### Phase 3 — Location API modernization
|
|
85
|
+
|
|
86
|
+
- Android `ActivityRecognitionLocationProvider`: `LocationRequest.Builder` + `Priority.PRIORITY_*` (replaces deprecated `LocationRequest.create()`, `setPriority/setInterval/setFastestInterval`, `LocationRequest.PRIORITY_*`).
|
|
87
|
+
- Android `RawLocationProvider`: removed `Criteria` and `getBestProvider`; explicit GPS-first / Network-fallback selection.
|
|
88
|
+
- `plugin.xml`: `GOOGLE_PLAY_SERVICES_VERSION` default raised to `21.0.1`.
|
|
89
|
+
- iOS `MAURPostLocationTask`: `NSURLConnection` (deprecated iOS 9) replaced with `NSURLSession dataTaskWithRequest:` + `dispatch_semaphore` for the synchronous post path.
|
|
90
|
+
- iOS `MAURDistanceFilterLocationProvider`: added `locationManagerDidChangeAuthorization:` (iOS 14+) alongside the legacy callback; short-circuit legacy on iOS 14+ to avoid double notifications.
|
|
91
|
+
- iOS `MAURConfig` + `MAURDistanceFilterLocationProvider`: new `showsBackgroundLocationIndicator` config (iOS 11+).
|
|
92
|
+
- TypeScript: `showsBackgroundLocationIndicator?: boolean` added to `ConfigureOptions`.
|
|
93
|
+
- `cordova-ios >= 6.2.0` required for `3.4.0` (runtime `@available` checks gate iOS 11/14 APIs).
|
|
94
|
+
|
|
95
|
+
- Android `DistanceFilterLocationProvider`: `Criteria` API fully removed; `getBestProvider(criteria, true)` replaced by explicit `pickProvider()`; `requestSingleUpdate(criteria, ...)` replaced by the provider-string overload.
|
|
96
|
+
- Bug: iOS `activitiesInterval` parsing in `MAURConfig.fromDictionary` had inverted `isNull` check; fixed.
|
|
97
|
+
- Bug: Android `Content-Length` used `String.length()` (chars) instead of UTF-8 byte length; fixed in `HttpPostService.postJSONString`.
|
|
98
|
+
|
|
99
|
+
Notes (still legacy but functional):
|
|
100
|
+
- `LocationManager.getLastKnownLocation` kept (not deprecated).
|
|
101
|
+
- `LocationManager.requestSingleUpdate(String, PendingIntent)` kept (modern `getCurrentLocation` does not accept `PendingIntent`).
|
|
102
|
+
- `AlarmManager.setInexactRepeating` kept for stationary polling; planned FGS-driven replacement.
|
|
103
|
+
|
|
104
|
+
## [3.3.0] - 2026-05-07
|
|
105
|
+
|
|
106
|
+
### Phase 2 — Backend-agnostic HTTP transport
|
|
107
|
+
|
|
108
|
+
- Added: `httpMethod`, `syncHttpMethod` (`POST` default, also `GET`, `PUT`, `PATCH`).
|
|
109
|
+
- Added: `httpMode`, `syncMode` (`batch` default, `single` for one request per location). `single` is required with `GET`.
|
|
110
|
+
- Added: URL templating with placeholders `{latitude}`, `{longitude}`, `{lat}`, `{lon}`, `{time}`, `{timestamp}`, `{timestamp_iso}`, `{speed}`, `{altitude}`, `{bearing}`, `{accuracy}`, `{provider}` plus any keys from `queryParams`.
|
|
111
|
+
- Added: `queryParams`, `headers` (alias of `httpHeaders`), `bodyTemplate` (alias of `postTemplate`).
|
|
112
|
+
- Added: helpers `com.marianhello.bgloc.http.UrlTemplateResolver` (Android) and `MAURUrlTemplateResolver` (iOS).
|
|
113
|
+
- Changed: `HttpPostService` (Android), `MAURPostLocationTask` and `MAURBackgroundSync` (iOS) no longer hardcode POST.
|
|
114
|
+
- Compatibility: existing apps using only `url` + `httpHeaders` + `postTemplate` keep working.
|
|
115
|
+
|
|
116
|
+
### Phase 1 — Auto-start Android
|
|
117
|
+
|
|
118
|
+
- Added: `ACCESS_BACKGROUND_LOCATION` permission, validated at runtime on Android 10+ before starting the foreground service.
|
|
119
|
+
- Added: boot receiver also handles `QUICKBOOT_POWERON` (HTC, MIUI), `com.htc.intent.action.QUICKBOOT_POWERON`, and `MY_PACKAGE_REPLACED` (service is relaunched after app updates).
|
|
120
|
+
- Added: `ForegroundServiceStartNotAllowedException` (Android 12+) is now caught with clear logging in `BootCompletedReceiver` and `LocationServiceProxy`. WorkManager is not used as a tracking fallback (only for deferred sync).
|
|
121
|
+
- Changed: `foregroundServiceType` simplified to `"location"`; `LocationServiceImpl.startForeground()` reads the type dynamically from the manifest instead of hardcoding `0x8`.
|
|
122
|
+
- Changed: `LocationServiceProxy.startForegroundService()` no longer falls back to `startService()` when location permission is missing — it logs and exits.
|
|
123
|
+
- Changed: `engines` raised to `cordova >= 10.0.0` and `cordova-android >= 12.0.0`.
|
|
124
|
+
- Removed: `FOREGROUND_SERVICE_DATA_SYNC` permission and `dataSync` from `foregroundServiceType`.
|
|
125
|
+
- Removed: `<uses-library org.apache.http.legacy>` and `useLibrary 'org.apache.http.legacy'` (no longer used; the plugin uses `HttpURLConnection`).
|
|
126
|
+
- Removed: dead constant `FOREGROUND_SERVICE_TYPE_LOCATION = 4` in `LocationServiceImpl.java` (incorrect value; never referenced).
|
|
127
|
+
- Build: `jcenter()` → `mavenCentral()` in `android/build.gradle`.
|
|
128
|
+
- Docs: planning docs `docs/auto-start.md`, `docs/http-transport.md`, `docs/traccar.md`, `docs/driving-events.md`, `docs/ROADMAP.md`, `docs/location-modernization.md` (Fase 3 / v3.4). Audit in `REVIEW_3.2.0.md` (§8–§9 alineados al roadmap vigente).
|
|
129
|
+
|
|
5
130
|
## [3.2.0] - 2026-02-28
|
|
6
131
|
|
|
7
132
|
### Added
|