@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.
Files changed (51) hide show
  1. package/.npmignore +4 -0
  2. package/CHANGELOG.md +290 -0
  3. package/CLAUDE.md +56 -0
  4. package/HISTORY.md +125 -0
  5. package/README.md +189 -4
  6. package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +90 -0
  7. package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +310 -1
  8. package/android/common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +127 -0
  9. package/android/common/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +27 -11
  10. package/android/common/src/main/java/com/marianhello/bgloc/Config.java +268 -0
  11. package/android/common/src/main/java/com/marianhello/bgloc/HttpPostService.java +86 -26
  12. package/android/common/src/main/java/com/marianhello/bgloc/PluginDelegate.java +26 -0
  13. package/android/common/src/main/java/com/marianhello/bgloc/PostLocationTask.java +42 -5
  14. package/android/common/src/main/java/com/marianhello/bgloc/driving/DrivingEventsDetector.java +265 -0
  15. package/android/common/src/main/java/com/marianhello/bgloc/http/UrlTemplateResolver.java +115 -0
  16. package/android/common/src/main/java/com/marianhello/bgloc/oem/BatteryOemHelper.java +214 -0
  17. package/android/common/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +13 -9
  18. package/android/common/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +29 -40
  19. package/android/common/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +14 -34
  20. package/android/common/src/main/java/com/marianhello/bgloc/sensor/SensorFusionDetector.java +199 -0
  21. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +305 -6
  22. package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +14 -2
  23. package/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +50 -3
  24. package/android/dependencies.gradle +0 -3
  25. package/angular/background-geolocation-events.ts +21 -0
  26. package/angular/background-geolocation.service.ts +63 -0
  27. package/angular/dist/background-geolocation-events.d.ts +18 -1
  28. package/angular/dist/background-geolocation.service.d.ts +36 -0
  29. package/angular/dist/esm2022/background-geolocation-events.mjs +22 -1
  30. package/angular/dist/esm2022/background-geolocation.service.mjs +35 -1
  31. package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs +55 -0
  32. package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs.map +1 -1
  33. package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +312 -1
  34. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +22 -0
  35. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +400 -15
  36. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +12 -0
  37. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +83 -5
  38. package/ios/common/BackgroundGeolocation/MAURConfig.h +15 -0
  39. package/ios/common/BackgroundGeolocation/MAURConfig.m +100 -3
  40. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +29 -2
  41. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +4 -0
  42. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +97 -44
  43. package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.h +41 -0
  44. package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.m +137 -0
  45. package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.h +31 -0
  46. package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.m +107 -0
  47. package/package.json +41 -1
  48. package/plugin.xml +19 -8
  49. package/www/BackgroundGeolocation.d.ts +517 -3
  50. package/www/BackgroundGeolocation.js +54 -1
  51. package/RELEASE.MD +0 -16
@@ -13,6 +13,10 @@
13
13
  #import "MAURConfig.h"
14
14
  #import "MAURBackgroundGeolocationFacade.h"
15
15
  #import "MAURBackgroundTaskManager.h"
16
+ #import "MAURSQLiteLocationDAO.h"
17
+ #import "MAURBackgroundSync.h"
18
+ #import <CoreMotion/CoreMotion.h>
19
+ #import <UIKit/UIKit.h>
16
20
 
17
21
  static NSString * const TAG = @"CDVBackgroundGeolocation";
18
22
 
@@ -35,6 +39,219 @@ static NSString * const TAG = @"CDVBackgroundGeolocation";
35
39
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppResume:) name:UIApplicationWillEnterForegroundNotification object:nil];
36
40
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil];
37
41
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate:) name:UIApplicationWillTerminateNotification object:nil];
42
+
43
+ // v3.5 Phase 4: forward sync notifications from MAURBackgroundSync into JS events.
44
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncStart:) name:MAURBackgroundSyncDidStartNotification object:nil];
45
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncSuccess:) name:MAURBackgroundSyncDidSucceedNotification object:nil];
46
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncError:) name:MAURBackgroundSyncDidFailNotification object:nil];
47
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSyncProgress:) name:MAURBackgroundSyncDidProgressNotification object:nil];
48
+ // v3.5 Phase 4: forward heartbeat notification from the facade timer into JS events.
49
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onHeartbeat:) name:MAURHeartbeatNotification object:nil];
50
+
51
+ // v4.0 Phase 6: forward driver-insights notifications.
52
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTripStartN:) name:MAURTripStartNotification object:nil];
53
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTripEndN:) name:MAURTripEndNotification object:nil];
54
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMovingN:) name:MAURMovingNotification object:nil];
55
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onStoppedN:) name:MAURStoppedNotification object:nil];
56
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSpeedingN:) name:MAURSpeedingNotification object:nil];
57
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onProviderChangeN:) name:MAURProviderChangeNotification object:nil];
58
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSOSN:) name:MAURSOSNotification object:nil];
59
+ // v4.1 GPS-derived sensor-like events
60
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onHardBrakeN:) name:MAURHardBrakeNotification object:nil];
61
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onRapidAccelerationN:) name:MAURRapidAccelerationNotification object:nil];
62
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onSharpTurnN:) name:MAURSharpTurnNotification object:nil];
63
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPossibleCrashN:) name:MAURPossibleCrashNotification object:nil];
64
+ // v4.2 sensor fusion
65
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPhoneUsageWhileDrivingN:) name:MAURPhoneUsageWhileDrivingNotification object:nil];
66
+ }
67
+
68
+ #pragma mark - v4.0 Phase 6 driver-insight observers
69
+
70
+ - (void) onTripStartN:(NSNotification *)note
71
+ {
72
+ MAURLocation *loc = note.userInfo[@"location"];
73
+ if (loc != nil) [self sendEvent:@"tripStart" result:[loc toDictionaryWithId]];
74
+ else [self sendEvent:@"tripStart"];
75
+ }
76
+
77
+ - (void) onTripEndN:(NSNotification *)note
78
+ {
79
+ NSMutableDictionary *p = [NSMutableDictionary dictionary];
80
+ MAURLocation *loc = note.userInfo[@"location"];
81
+ p[@"location"] = loc != nil ? [loc toDictionaryWithId] : [NSNull null];
82
+ p[@"distance"] = note.userInfo[@"distance"] ?: @0;
83
+ p[@"durationMs"] = note.userInfo[@"durationMs"] ?: @0;
84
+ [self sendEvent:@"tripEnd" result:p];
85
+ }
86
+
87
+ - (void) onMovingN:(NSNotification *)note
88
+ {
89
+ MAURLocation *loc = note.userInfo[@"location"];
90
+ if (loc != nil) [self sendEvent:@"moving" result:[loc toDictionaryWithId]];
91
+ else [self sendEvent:@"moving"];
92
+ }
93
+
94
+ - (void) onStoppedN:(NSNotification *)note
95
+ {
96
+ MAURLocation *loc = note.userInfo[@"location"];
97
+ if (loc != nil) [self sendEvent:@"stopped" result:[loc toDictionaryWithId]];
98
+ else [self sendEvent:@"stopped"];
99
+ }
100
+
101
+ - (void) onSpeedingN:(NSNotification *)note
102
+ {
103
+ NSMutableDictionary *p = [NSMutableDictionary dictionary];
104
+ MAURLocation *loc = note.userInfo[@"location"];
105
+ p[@"location"] = loc != nil ? [loc toDictionaryWithId] : [NSNull null];
106
+ p[@"speedKmh"] = note.userInfo[@"speedKmh"] ?: @0;
107
+ p[@"limitKmh"] = note.userInfo[@"limitKmh"] ?: @0;
108
+ [self sendEvent:@"speeding" result:p];
109
+ }
110
+
111
+ - (void) onProviderChangeN:(NSNotification *)note
112
+ {
113
+ NSDictionary *p = @{ @"provider": note.userInfo[@"provider"] ?: @"" };
114
+ [self sendEvent:@"providerChange" result:p];
115
+ }
116
+
117
+ - (void) onSOSN:(NSNotification *)note
118
+ {
119
+ NSMutableDictionary *p = [NSMutableDictionary dictionary];
120
+ NSDictionary *userPayload = note.userInfo[@"payload"];
121
+ if ([userPayload isKindOfClass:[NSDictionary class]]) [p addEntriesFromDictionary:userPayload];
122
+ MAURLocation *loc = note.userInfo[@"location"];
123
+ if (loc != nil) p[@"location"] = [loc toDictionaryWithId];
124
+ [self sendEvent:@"sos" result:p];
125
+ }
126
+
127
+ - (void) triggerSOS:(CDVInvokedUrlCommand *)command
128
+ {
129
+ NSDictionary *payload = nil;
130
+ if (command.arguments.count > 0 && [command.arguments[0] isKindOfClass:[NSDictionary class]]) {
131
+ payload = command.arguments[0];
132
+ }
133
+ [facade triggerSOS:payload];
134
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
135
+ callbackId:command.callbackId];
136
+ }
137
+
138
+ // v4.1 GPS-derived sensor-like events
139
+ - (void) sendDrivingEventN:(NSString *)name note:(NSNotification *)note
140
+ {
141
+ NSMutableDictionary *p = [NSMutableDictionary dictionary];
142
+ MAURLocation *loc = note.userInfo[@"location"];
143
+ p[@"location"] = loc != nil ? [loc toDictionaryWithId] : [NSNull null];
144
+ p[@"value"] = note.userInfo[@"value"] ?: @0;
145
+ if (note.userInfo[@"source"] != nil) p[@"source"] = note.userInfo[@"source"];
146
+ [self sendEvent:name result:p];
147
+ }
148
+ - (void) onHardBrakeN:(NSNotification *)n { [self sendDrivingEventN:@"hardBrake" note:n]; }
149
+ - (void) onRapidAccelerationN:(NSNotification *)n { [self sendDrivingEventN:@"rapidAcceleration" note:n]; }
150
+ - (void) onSharpTurnN:(NSNotification *)n { [self sendDrivingEventN:@"sharpTurn" note:n]; }
151
+ - (void) onPossibleCrashN:(NSNotification *)n { [self sendDrivingEventN:@"possibleCrash" note:n]; }
152
+ // v4.2 sensor fusion
153
+ - (void) onPhoneUsageWhileDrivingN:(NSNotification *)note
154
+ {
155
+ MAURLocation *loc = note.userInfo[@"location"];
156
+ if (loc != nil) [self sendEvent:@"phoneUsageWhileDriving" result:[loc toDictionaryWithId]];
157
+ else [self sendEvent:@"phoneUsageWhileDriving"];
158
+ }
159
+
160
+ - (void) onSyncStart:(NSNotification *)note
161
+ {
162
+ [self sendEvent:@"syncStart"];
163
+ }
164
+
165
+ - (void) onSyncSuccess:(NSNotification *)note
166
+ {
167
+ NSDictionary *info = note.userInfo ?: @{};
168
+ [self sendEvent:@"syncSuccess" result:@{@"sent": info[@"sent"] ?: @0}];
169
+ }
170
+
171
+ - (void) onSyncError:(NSNotification *)note
172
+ {
173
+ NSDictionary *info = note.userInfo ?: @{};
174
+ [self sendEvent:@"syncError" result:@{
175
+ @"httpStatus": info[@"httpStatus"] ?: @0,
176
+ @"message": info[@"message"] ?: @""
177
+ }];
178
+ }
179
+
180
+ - (void) onSyncProgress:(NSNotification *)note
181
+ {
182
+ NSDictionary *info = note.userInfo ?: @{};
183
+ [self sendEvent:@"syncProgress" resultAsNumber:(info[@"progress"] ?: @0)];
184
+ }
185
+
186
+ - (void) onHeartbeat:(NSNotification *)note
187
+ {
188
+ NSDictionary *info = note.userInfo ?: @{};
189
+ MAURLocation *loc = info[@"location"];
190
+ if (loc != nil) {
191
+ [self sendEvent:@"heartbeat" result:[loc toDictionaryWithId]];
192
+ } else {
193
+ [self sendEvent:@"heartbeat"];
194
+ }
195
+ }
196
+
197
+ // v3.6 Phase 5 — Battery / OEM helpers. iOS does not expose Doze whitelist or
198
+ // vendor "auto-start" screens, so these are best-effort no-ops that resolve true
199
+ // (whitelist concept N/A) or open the app's Settings entry.
200
+
201
+ - (void) isIgnoringBatteryOptimizations:(CDVInvokedUrlCommand *)command
202
+ {
203
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]
204
+ callbackId:command.callbackId];
205
+ }
206
+
207
+ - (void) requestIgnoreBatteryOptimizations:(CDVInvokedUrlCommand *)command
208
+ {
209
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]
210
+ callbackId:command.callbackId];
211
+ }
212
+
213
+ - (void) openBatterySettings:(CDVInvokedUrlCommand *)command
214
+ {
215
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
216
+ if (url != nil && [[UIApplication sharedApplication] canOpenURL:url]) {
217
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
218
+ }
219
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
220
+ callbackId:command.callbackId];
221
+ }
222
+
223
+ - (void) openAutoStartSettings:(CDVInvokedUrlCommand *)command
224
+ {
225
+ // iOS has no per-OEM auto-start screen. Open the app's Settings entry as a best-effort
226
+ // and report opened=false so the JS layer can decide whether to render a help screen.
227
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
228
+ BOOL opened = NO;
229
+ if (url != nil && [[UIApplication sharedApplication] canOpenURL:url]) {
230
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
231
+ opened = YES;
232
+ }
233
+ NSDictionary *info = @{
234
+ @"opened": @(opened),
235
+ @"manufacturer": @"apple",
236
+ @"screen": @"UIApplicationOpenSettingsURLString"
237
+ };
238
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info]
239
+ callbackId:command.callbackId];
240
+ }
241
+
242
+ - (void) getManufacturerHelp:(CDVInvokedUrlCommand *)command
243
+ {
244
+ NSDictionary *info = @{
245
+ @"manufacturer": @"apple",
246
+ @"steps": @[
247
+ @"Settings → Privacy & Security → Location Services → [your app] → Always.",
248
+ @"Settings → Privacy & Security → Location Services → [your app] → Precise Location → ON.",
249
+ @"Settings → General → Background App Refresh → enable globally and for [your app].",
250
+ @"Settings → Battery → Low Power Mode → off (Low Power Mode pauses background activity)."
251
+ ]
252
+ };
253
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info]
254
+ callbackId:command.callbackId];
38
255
  }
39
256
 
40
257
  /**
@@ -153,6 +370,100 @@ static NSString * const TAG = @"CDVBackgroundGeolocation";
153
370
  }];
154
371
  }
155
372
 
373
+ /**
374
+ * v3.5 Phase 4: extended diagnostics. Returns permissions, precise location,
375
+ * background refresh, low power and motion authorization on iOS.
376
+ */
377
+ - (void) getDiagnostics:(CDVInvokedUrlCommand *)command
378
+ {
379
+ NSLog(@"%@ #%@", TAG, @"getDiagnostics");
380
+ [self.commandDelegate runInBackground:^{
381
+ NSMutableDictionary *d = [NSMutableDictionary dictionary];
382
+
383
+ // Common
384
+ [d setObject:[NSNumber numberWithBool:[facade isStarted]] forKey:@"isRunning"];
385
+ [d setObject:[NSNumber numberWithBool:[facade locationServicesEnabled]] forKey:@"locationServicesEnabled"];
386
+
387
+ // Authorization status (raw + human-readable)
388
+ CLAuthorizationStatus status;
389
+ if (@available(iOS 14.0, *)) {
390
+ CLLocationManager *lm = [[CLLocationManager alloc] init];
391
+ status = lm.authorizationStatus;
392
+ // accuracyAuthorization (Precise vs Reduced)
393
+ BOOL precise = (lm.accuracyAuthorization == CLAccuracyAuthorizationFullAccuracy);
394
+ [d setObject:[NSNumber numberWithBool:precise] forKey:@"preciseLocationEnabled"];
395
+ } else {
396
+ status = [CLLocationManager authorizationStatus];
397
+ // Pre-iOS 14 had no Reduced accuracy concept; report YES.
398
+ [d setObject:[NSNumber numberWithBool:YES] forKey:@"preciseLocationEnabled"];
399
+ }
400
+ [d setObject:[NSNumber numberWithInteger:status] forKey:@"authorization"];
401
+ [d setObject:[self authorizationStatusText:status] forKey:@"authorizationStatusText"];
402
+
403
+ // Background App Refresh
404
+ [d setObject:[self backgroundRefreshStatusText] forKey:@"backgroundRefreshStatus"];
405
+
406
+ // Low Power Mode (iOS 9+)
407
+ if (@available(iOS 9.0, *)) {
408
+ [d setObject:[NSNumber numberWithBool:[NSProcessInfo processInfo].lowPowerModeEnabled]
409
+ forKey:@"lowPowerModeEnabled"];
410
+ } else {
411
+ [d setObject:[NSNumber numberWithBool:NO] forKey:@"lowPowerModeEnabled"];
412
+ }
413
+
414
+ // Motion authorization. Use the flag exposed by CMMotionActivityManager.
415
+ [d setObject:[self motionPermissionText] forKey:@"motionPermissionStatus"];
416
+
417
+ // Pending sync count (best-effort).
418
+ @try {
419
+ NSNumber *pending = [[MAURSQLiteLocationDAO sharedInstance] getLocationsForSyncCount];
420
+ [d setObject:(pending != nil ? pending : [NSNumber numberWithInt:0]) forKey:@"pendingSyncCount"];
421
+ } @catch (NSException *e) {
422
+ [d setObject:[NSNumber numberWithInt:0] forKey:@"pendingSyncCount"];
423
+ }
424
+
425
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:d];
426
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
427
+ }];
428
+ }
429
+
430
+ - (NSString *) authorizationStatusText:(CLAuthorizationStatus)status
431
+ {
432
+ switch (status) {
433
+ case kCLAuthorizationStatusNotDetermined: return @"notDetermined";
434
+ case kCLAuthorizationStatusRestricted: return @"restricted";
435
+ case kCLAuthorizationStatusDenied: return @"denied";
436
+ case kCLAuthorizationStatusAuthorizedAlways: return @"authorizedAlways";
437
+ case kCLAuthorizationStatusAuthorizedWhenInUse: return @"authorizedWhenInUse";
438
+ }
439
+ return @"unknown";
440
+ }
441
+
442
+ - (NSString *) backgroundRefreshStatusText
443
+ {
444
+ UIBackgroundRefreshStatus s = [UIApplication sharedApplication].backgroundRefreshStatus;
445
+ switch (s) {
446
+ case UIBackgroundRefreshStatusAvailable: return @"available";
447
+ case UIBackgroundRefreshStatusDenied: return @"denied";
448
+ case UIBackgroundRefreshStatusRestricted: return @"restricted";
449
+ }
450
+ return @"unknown";
451
+ }
452
+
453
+ - (NSString *) motionPermissionText
454
+ {
455
+ if (![CMMotionActivityManager isActivityAvailable]) return @"restricted";
456
+ if (@available(iOS 11.0, *)) {
457
+ switch ([CMMotionActivityManager authorizationStatus]) {
458
+ case CMAuthorizationStatusNotDetermined: return @"notDetermined";
459
+ case CMAuthorizationStatusRestricted: return @"restricted";
460
+ case CMAuthorizationStatusDenied: return @"denied";
461
+ case CMAuthorizationStatusAuthorized: return @"authorized";
462
+ }
463
+ }
464
+ return @"notDetermined";
465
+ }
466
+
156
467
  /**
157
468
  * Fetches current stationaryLocation
158
469
  */
@@ -202,7 +513,7 @@ static NSString * const TAG = @"CDVBackgroundGeolocation";
202
513
  - (void) getPluginVersion:(CDVInvokedUrlCommand*)command
203
514
  {
204
515
  NSLog(@"%@ #%@", TAG, @"getPluginVersion");
205
- NSString *version = @"3.2.0"; // keep in sync with plugin.xml
516
+ NSString *version = @"4.2.2"; // keep in sync with plugin.xml and Android PLUGIN_VERSION
206
517
  CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:version];
207
518
  [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
208
519
  }
@@ -16,6 +16,26 @@
16
16
  #import "MAURLocation.h"
17
17
  #import "MAURConfig.h"
18
18
 
19
+ // v3.5 Phase 4: heartbeat notification. userInfo[@"location"] is the latest MAURLocation
20
+ // (may be absent if no fix has been received yet).
21
+ extern NSString * _Nonnull const MAURHeartbeatNotification;
22
+
23
+ // v4.0 Phase 6: driver-insight notifications. userInfo carries `location` and event-specific keys.
24
+ extern NSString * _Nonnull const MAURTripStartNotification;
25
+ extern NSString * _Nonnull const MAURTripEndNotification; // userInfo: location, distance, durationMs
26
+ extern NSString * _Nonnull const MAURMovingNotification;
27
+ extern NSString * _Nonnull const MAURStoppedNotification;
28
+ extern NSString * _Nonnull const MAURSpeedingNotification; // userInfo: location, speedKmh, limitKmh
29
+ extern NSString * _Nonnull const MAURProviderChangeNotification;// userInfo: provider
30
+ extern NSString * _Nonnull const MAURSOSNotification; // userInfo: location, payload (NSDictionary)
31
+ // v4.1 GPS-derived sensor-like events. userInfo: location, value (double)
32
+ extern NSString * _Nonnull const MAURHardBrakeNotification;
33
+ extern NSString * _Nonnull const MAURRapidAccelerationNotification;
34
+ extern NSString * _Nonnull const MAURSharpTurnNotification;
35
+ extern NSString * _Nonnull const MAURPossibleCrashNotification;
36
+ // v4.2 sensor fusion events. userInfo: location, source ("gps"|"sensor"), value (double)
37
+ extern NSString * _Nonnull const MAURPhoneUsageWhileDrivingNotification;
38
+
19
39
  @interface MAURBackgroundGeolocationFacade : NSObject
20
40
 
21
41
  @property (weak, nonatomic) id<MAURProviderDelegate> delegate;
@@ -41,6 +61,8 @@
41
61
  - (MAURConfig*) getConfig;
42
62
  - (NSArray*) getLogEntries:(NSInteger)limit;
43
63
  - (NSArray*) getLogEntries:(NSInteger)limit fromLogEntryId:(NSInteger)entryId minLogLevelFromString:(NSString *)minLogLevel;
64
+ /** v4.0 Phase 6 — Trigger an SOS event with the latest known location and a user payload. */
65
+ - (void) triggerSOS:(NSDictionary * _Nullable)payload;
44
66
  - (void) forceSync;
45
67
  - (void) clearSync;
46
68
  - (NSInteger) getPendingSyncCount;