react-native-nitro-location-tracking 0.1.5 → 0.1.6

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 (76) hide show
  1. package/README.md +677 -7
  2. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/GeofenceManager.kt +148 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationEngine.kt +55 -1
  4. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +127 -0
  5. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/ProviderStatusMonitor.kt +73 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/SpeedMonitor.kt +38 -0
  7. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/TripCalculator.kt +85 -0
  8. package/ios/GeofenceManager.swift +69 -0
  9. package/ios/LocationEngine.swift +56 -2
  10. package/ios/NitroLocationTracking.swift +104 -0
  11. package/ios/SpeedMonitor.swift +48 -0
  12. package/ios/TripCalculator.swift +93 -0
  13. package/lib/module/index.js.map +1 -1
  14. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +44 -0
  15. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
  16. package/lib/typescript/src/index.d.ts +1 -1
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/test.d.ts +1 -0
  19. package/lib/typescript/test.d.ts.map +1 -0
  20. package/nitrogen/generated/android/c++/JFunc_void_GeofenceEvent_std__string.hpp +78 -0
  21. package/nitrogen/generated/android/c++/JFunc_void_LocationData.hpp +1 -0
  22. package/nitrogen/generated/android/c++/JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp +77 -0
  23. package/nitrogen/generated/android/c++/JFunc_void_SpeedAlertType_double.hpp +77 -0
  24. package/nitrogen/generated/android/c++/JGeofenceEvent.hpp +58 -0
  25. package/nitrogen/generated/android/c++/JGeofenceRegion.hpp +77 -0
  26. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +102 -0
  27. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +16 -0
  28. package/nitrogen/generated/android/c++/JLocationData.hpp +8 -4
  29. package/nitrogen/generated/android/c++/JLocationProviderStatus.hpp +58 -0
  30. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +67 -0
  31. package/nitrogen/generated/android/c++/JSpeedAlertType.hpp +61 -0
  32. package/nitrogen/generated/android/c++/JSpeedConfig.hpp +65 -0
  33. package/nitrogen/generated/android/c++/JTripStats.hpp +73 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_GeofenceEvent_std__string.kt +80 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_LocationProviderStatus_LocationProviderStatus.kt +80 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_SpeedAlertType_double.kt +80 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/GeofenceEvent.kt +23 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/GeofenceRegion.kt +53 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +79 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationData.kt +6 -3
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationProviderStatus.kt +23 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/PermissionStatus.kt +26 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/SpeedAlertType.kt +24 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/SpeedConfig.kt +44 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/TripStats.kt +50 -0
  46. package/nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp +6 -0
  47. package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.cpp +24 -0
  48. package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.hpp +124 -0
  49. package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Umbrella.hpp +22 -0
  50. package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +130 -0
  51. package/nitrogen/generated/ios/swift/Func_void_GeofenceEvent_std__string.swift +46 -0
  52. package/nitrogen/generated/ios/swift/Func_void_LocationProviderStatus_LocationProviderStatus.swift +46 -0
  53. package/nitrogen/generated/ios/swift/Func_void_SpeedAlertType_double.swift +46 -0
  54. package/nitrogen/generated/ios/swift/GeofenceEvent.swift +40 -0
  55. package/nitrogen/generated/ios/swift/GeofenceRegion.swift +54 -0
  56. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +16 -0
  57. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +197 -0
  58. package/nitrogen/generated/ios/swift/LocationData.swift +20 -2
  59. package/nitrogen/generated/ios/swift/LocationProviderStatus.swift +40 -0
  60. package/nitrogen/generated/ios/swift/PermissionStatus.swift +52 -0
  61. package/nitrogen/generated/ios/swift/SpeedAlertType.swift +44 -0
  62. package/nitrogen/generated/ios/swift/SpeedConfig.swift +39 -0
  63. package/nitrogen/generated/ios/swift/TripStats.swift +49 -0
  64. package/nitrogen/generated/shared/c++/GeofenceEvent.hpp +76 -0
  65. package/nitrogen/generated/shared/c++/GeofenceRegion.hpp +103 -0
  66. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +16 -0
  67. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +37 -0
  68. package/nitrogen/generated/shared/c++/LocationData.hpp +7 -3
  69. package/nitrogen/generated/shared/c++/LocationProviderStatus.hpp +76 -0
  70. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +88 -0
  71. package/nitrogen/generated/shared/c++/SpeedAlertType.hpp +80 -0
  72. package/nitrogen/generated/shared/c++/SpeedConfig.hpp +91 -0
  73. package/nitrogen/generated/shared/c++/TripStats.hpp +99 -0
  74. package/package.json +2 -2
  75. package/src/NitroLocationTracking.nitro.ts +71 -0
  76. package/src/index.tsx +10 -0
@@ -16,6 +16,10 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
16
16
  var onMotionChange: ((Bool) -> Void)?
17
17
  var dbWriter: NativeDBWriter?
18
18
  var currentRideId: String?
19
+ var rejectMockLocations: Bool = false
20
+ let speedMonitor = SpeedMonitor()
21
+ let tripCalculator = TripCalculator()
22
+ var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Void)?
19
23
 
20
24
  override init() {
21
25
  super.init()
@@ -67,7 +71,8 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
67
71
  speed: max(lastLocation.speed, 0),
68
72
  bearing: max(lastLocation.course, 0),
69
73
  accuracy: lastLocation.horizontalAccuracy,
70
- timestamp: lastLocation.timestamp.timeIntervalSince1970 * 1000
74
+ timestamp: lastLocation.timestamp.timeIntervalSince1970 * 1000,
75
+ isMockLocation: Self.isLocationMock(lastLocation)
71
76
  )
72
77
  completion(data)
73
78
  return
@@ -85,6 +90,8 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
85
90
  didUpdateLocations locations: [CLLocation]) {
86
91
  guard let location = locations.last else { return }
87
92
 
93
+ let isMock = Self.isLocationMock(location)
94
+
88
95
  let data = LocationData(
89
96
  latitude: location.coordinate.latitude,
90
97
  longitude: location.coordinate.longitude,
@@ -92,7 +99,8 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
92
99
  speed: max(location.speed, 0),
93
100
  bearing: max(location.course, 0),
94
101
  accuracy: location.horizontalAccuracy,
95
- timestamp: location.timestamp.timeIntervalSince1970 * 1000
102
+ timestamp: location.timestamp.timeIntervalSince1970 * 1000,
103
+ isMockLocation: isMock
96
104
  )
97
105
 
98
106
  // Handle pending one-shot request (from oneShotManager)
@@ -105,9 +113,18 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
105
113
  // Continuous updates from locationManager only
106
114
  guard manager === locationManager else { return }
107
115
 
116
+ // Skip mock locations if rejection is enabled
117
+ if rejectMockLocations && isMock {
118
+ return
119
+ }
120
+
108
121
  // Notify JS via Nitro callback
109
122
  onLocation?(data)
110
123
 
124
+ // Feed to speed monitor and trip calculator
125
+ speedMonitor.feedLocation(data)
126
+ tripCalculator.feedLocation(data)
127
+
111
128
  // Motion detection
112
129
  onMotionChange?(location.speed >= 0.5)
113
130
  }
@@ -119,6 +136,43 @@ class LocationEngine: NSObject, CLLocationManagerDelegate {
119
136
  pendingLocationCompletion = nil
120
137
  }
121
138
  }
139
+
140
+ // MARK: - Mock Location Detection
141
+
142
+ private static func isLocationMock(_ location: CLLocation) -> Bool {
143
+ if #available(iOS 15.0, *) {
144
+ if let sourceInfo = location.sourceInformation {
145
+ return sourceInfo.isSimulatedBySoftware
146
+ }
147
+ }
148
+ // Fallback: detect simulator at compile time
149
+ #if targetEnvironment(simulator)
150
+ return true
151
+ #else
152
+ return false
153
+ #endif
154
+ }
155
+
156
+ func isFakeGpsEnabled() -> Bool {
157
+ #if targetEnvironment(simulator)
158
+ return true
159
+ #else
160
+ return false
161
+ #endif
162
+ }
163
+
164
+ // MARK: - Location Provider Status
165
+
166
+ func isLocationServicesEnabled() -> Bool {
167
+ return CLLocationManager.locationServicesEnabled()
168
+ }
169
+
170
+ func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
171
+ guard manager === locationManager else { return }
172
+ let enabled = CLLocationManager.locationServicesEnabled()
173
+ let status: LocationProviderStatus = enabled ? .enabled : .disabled
174
+ providerStatusCallback?(status, status)
175
+ }
122
176
  }
123
177
 
124
178
 
@@ -7,11 +7,15 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
7
7
  private let connectionManager = ConnectionManager()
8
8
  private let dbWriter = NativeDBWriter()
9
9
  private let notificationService = NotificationService()
10
+ private let geofenceManager = GeofenceManager()
10
11
 
11
12
  private var locationCallback: ((LocationData) -> Void)?
12
13
  private var motionCallback: ((Bool) -> Void)?
13
14
  private var connectionStateCallback: ((ConnectionState) -> Void)?
14
15
  private var messageCallback: ((String) -> Void)?
16
+ private var geofenceCallback: ((GeofenceEvent, String) -> Void)?
17
+ private var speedAlertCallback: ((SpeedAlertType, Double) -> Void)?
18
+ private var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Void)?
15
19
 
16
20
  override init() {
17
21
  super.init()
@@ -108,6 +112,105 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
108
112
  return Promise.resolved(withResult: result)
109
113
  }
110
114
 
115
+ // MARK: - Fake GPS Detection
116
+
117
+ func isFakeGpsEnabled() throws -> Bool {
118
+ return locationEngine.isFakeGpsEnabled()
119
+ }
120
+
121
+ func setRejectMockLocations(reject: Bool) throws {
122
+ locationEngine.rejectMockLocations = reject
123
+ }
124
+
125
+ // MARK: - Geofencing
126
+
127
+ func addGeofence(region: GeofenceRegion) throws {
128
+ geofenceManager.addGeofence(region)
129
+ }
130
+
131
+ func removeGeofence(regionId: String) throws {
132
+ geofenceManager.removeGeofence(regionId)
133
+ }
134
+
135
+ func removeAllGeofences() throws {
136
+ geofenceManager.removeAllGeofences()
137
+ }
138
+
139
+ func onGeofenceEvent(callback: @escaping (GeofenceEvent, String) -> Void) throws {
140
+ geofenceCallback = callback
141
+ geofenceManager.setCallback(callback)
142
+ }
143
+
144
+ // MARK: - Speed Monitoring
145
+
146
+ func configureSpeedMonitor(config: SpeedConfig) throws {
147
+ locationEngine.speedMonitor.configure(config)
148
+ }
149
+
150
+ func onSpeedAlert(callback: @escaping (SpeedAlertType, Double) -> Void) throws {
151
+ speedAlertCallback = callback
152
+ locationEngine.speedMonitor.setCallback(callback)
153
+ }
154
+
155
+ func getCurrentSpeed() throws -> Double {
156
+ return locationEngine.speedMonitor.getCurrentSpeed()
157
+ }
158
+
159
+ // MARK: - Distance Calculator
160
+
161
+ func startTripCalculation() throws {
162
+ locationEngine.tripCalculator.start()
163
+ }
164
+
165
+ func stopTripCalculation() throws -> TripStats {
166
+ return locationEngine.tripCalculator.stop()
167
+ }
168
+
169
+ func getTripStats() throws -> TripStats {
170
+ return locationEngine.tripCalculator.getStats()
171
+ }
172
+
173
+ func resetTripCalculation() throws {
174
+ locationEngine.tripCalculator.reset()
175
+ }
176
+
177
+ // MARK: - Location Provider Status
178
+
179
+ func isLocationServicesEnabled() throws -> Bool {
180
+ return locationEngine.isLocationServicesEnabled()
181
+ }
182
+
183
+ func onProviderStatusChange(callback: @escaping (LocationProviderStatus, LocationProviderStatus) -> Void) throws {
184
+ providerStatusCallback = callback
185
+ locationEngine.providerStatusCallback = callback
186
+ }
187
+
188
+ // MARK: - Permission Status
189
+
190
+ func getLocationPermissionStatus() throws -> PermissionStatus {
191
+ let status: CLAuthorizationStatus
192
+ if #available(iOS 14.0, *) {
193
+ status = CLLocationManager().authorizationStatus
194
+ } else {
195
+ status = CLLocationManager.authorizationStatus()
196
+ }
197
+
198
+ switch status {
199
+ case .notDetermined:
200
+ return .notDetermined
201
+ case .restricted:
202
+ return .restricted
203
+ case .denied:
204
+ return .denied
205
+ case .authorizedWhenInUse:
206
+ return .whenInUse
207
+ case .authorizedAlways:
208
+ return .always
209
+ @unknown default:
210
+ return .notDetermined
211
+ }
212
+ }
213
+
111
214
  // MARK: - Notifications
112
215
 
113
216
  func showLocalNotification(title: String, body: String) throws {
@@ -123,5 +226,6 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
123
226
  func destroy() throws {
124
227
  locationEngine.stop()
125
228
  connectionManager.disconnect()
229
+ geofenceManager.destroy()
126
230
  }
127
231
  }
@@ -0,0 +1,48 @@
1
+ import Foundation
2
+
3
+ class SpeedMonitor {
4
+
5
+ private var config: SpeedConfig?
6
+ private var callback: ((SpeedAlertType, Double) -> Void)?
7
+ private var currentState: SpeedAlertType = .normalized
8
+ private var lastSpeedKmh: Double = 0.0
9
+
10
+ init() {
11
+ config = nil
12
+ callback = nil
13
+ }
14
+
15
+ func configure(_ config: SpeedConfig) {
16
+ self.config = config
17
+ }
18
+
19
+ func setCallback(_ callback: @escaping (SpeedAlertType, Double) -> Void) {
20
+ self.callback = callback
21
+ }
22
+
23
+ func getCurrentSpeed() -> Double {
24
+ return lastSpeedKmh
25
+ }
26
+
27
+ func feedLocation(_ data: LocationData) {
28
+ guard let cfg = config else { return }
29
+
30
+ let speedKmh = data.speed * 3.6 // m/s → km/h
31
+ lastSpeedKmh = speedKmh
32
+
33
+ let newState: SpeedAlertType
34
+ if speedKmh > cfg.maxSpeedKmh {
35
+ newState = .exceeded
36
+ } else if speedKmh < cfg.minSpeedKmh {
37
+ newState = .belowMinimum
38
+ } else {
39
+ newState = .normalized
40
+ }
41
+
42
+ // Only fire callback on state transitions
43
+ if newState != currentState {
44
+ currentState = newState
45
+ callback?(newState, speedKmh)
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,93 @@
1
+ import Foundation
2
+
3
+ class TripCalculator {
4
+
5
+ private var active = false
6
+ private var startTime: Date?
7
+ private var totalDistanceMeters: Double = 0.0
8
+ private var maxSpeedKmh: Double = 0.0
9
+ private var speedSumKmh: Double = 0.0
10
+ private var pointCount: Int = 0
11
+ private var lastLat: Double?
12
+ private var lastLon: Double?
13
+
14
+ var isActive: Bool { active }
15
+
16
+ init() {
17
+ startTime = nil
18
+ lastLat = nil
19
+ lastLon = nil
20
+ }
21
+
22
+ func start() {
23
+ reset()
24
+ active = true
25
+ startTime = Date()
26
+ }
27
+
28
+ func stop() -> TripStats {
29
+ active = false
30
+ return getStats()
31
+ }
32
+
33
+ func getStats() -> TripStats {
34
+ let durationMs: Double
35
+ if let start = startTime {
36
+ durationMs = Date().timeIntervalSince(start) * 1000
37
+ } else {
38
+ durationMs = 0
39
+ }
40
+ let avgSpeed = pointCount > 0 ? speedSumKmh / Double(pointCount) : 0
41
+ return TripStats(
42
+ distanceMeters: totalDistanceMeters,
43
+ durationMs: durationMs,
44
+ averageSpeedKmh: avgSpeed,
45
+ maxSpeedKmh: maxSpeedKmh,
46
+ pointCount: Double(pointCount)
47
+ )
48
+ }
49
+
50
+ func reset() {
51
+ active = false
52
+ startTime = nil
53
+ totalDistanceMeters = 0
54
+ maxSpeedKmh = 0
55
+ speedSumKmh = 0
56
+ pointCount = 0
57
+ lastLat = nil
58
+ lastLon = nil
59
+ }
60
+
61
+ func feedLocation(_ data: LocationData) {
62
+ guard active else { return }
63
+
64
+ let speedKmh = data.speed * 3.6 // m/s → km/h
65
+ if speedKmh > maxSpeedKmh { maxSpeedKmh = speedKmh }
66
+ speedSumKmh += speedKmh
67
+ pointCount += 1
68
+
69
+ let prevLat = lastLat
70
+ let prevLon = lastLon
71
+ lastLat = data.latitude
72
+ lastLon = data.longitude
73
+
74
+ if let pLat = prevLat, let pLon = prevLon {
75
+ totalDistanceMeters += Self.haversine(lat1: pLat, lon1: pLon,
76
+ lat2: data.latitude, lon2: data.longitude)
77
+ }
78
+ }
79
+
80
+ // MARK: - Haversine
81
+
82
+ private static let earthRadiusM: Double = 6371000.0
83
+
84
+ static func haversine(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> Double {
85
+ let dLat = (lat2 - lat1) * .pi / 180
86
+ let dLon = (lon2 - lon1) * .pi / 180
87
+ let a = sin(dLat / 2) * sin(dLat / 2) +
88
+ cos(lat1 * .pi / 180) * cos(lat2 * .pi / 180) *
89
+ sin(dLon / 2) * sin(dLon / 2)
90
+ let c = 2 * atan2(sqrt(a), sqrt(1 - a))
91
+ return earthRadiusM * c
92
+ }
93
+ }
@@ -1 +1 @@
1
- {"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,eAAeD,mBAAmB;AAClC,SAASE,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAW;AAC9D;;AAQA,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACiB,UAAU,EAAEC,aAAa,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;;EAEnD;EACA,MAAMmB,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC;;EAEzC;EACA,MAAMU,WAAW,GAAGnB,MAAM,CAAC,KAAK,CAAC;EAEjCF,SAAS,CAAC,MAAM;IACd,MAAMsB,MAAM,GAAGH,IAAI,CAACI,KAAK,CAACL,UAAU,CAAmB;IACvDd,mBAAmB,CAACoB,SAAS,CAACF,MAAM,CAAC;IACrClB,mBAAmB,CAACqB,UAAU,CAACZ,WAAW,CAAC;IAC3CT,mBAAmB,CAACsB,cAAc,CAACX,WAAW,CAAC;IAC/C,OAAO,MAAM;MACX,IAAIM,WAAW,CAACM,OAAO,EAAE;QACvBvB,mBAAmB,CAACwB,YAAY,CAA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,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAEzC,WAAW,CAAE0C,CAAS,IAAKvC,mBAAmB,CAACwC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,eAAeD,mBAAmB;AAClC,SAASE,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,cAAW;AAC9D;;AAkBA,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACe,QAAQ,EAAEC,WAAW,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACiB,UAAU,EAAEC,aAAa,CAAC,GAAGlB,QAAQ,CAAC,KAAK,CAAC;;EAEnD;EACA,MAAMmB,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC;;EAEzC;EACA,MAAMU,WAAW,G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mBAAmB,CAACiC,SAAS,CAACH,cAAc,CAAC;IAC7C,OAAO,MAAM;MACX9B,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAAC3B,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLoB,eAAe;IACfE,WAAW;IACXM,OAAO,EAAEtC,WAAW,CAAC,MAAMG,mBAAmB,CAACoC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC;IACtEC,UAAU,EAAExC,WAAW,CACrB,MAAMG,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAEzC,WAAW,CAAE0C,CAAS,IAAKvC,mBAAmB,CAACwC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
@@ -9,6 +9,7 @@ export interface LocationData {
9
9
  bearing: number;
10
10
  accuracy: number;
11
11
  timestamp: number;
12
+ isMockLocation?: boolean;
12
13
  }
13
14
  export interface LocationConfig {
14
15
  desiredAccuracy: AccuracyLevel;
@@ -33,6 +34,33 @@ export interface ConnectionConfig {
33
34
  export type LocationCallback = (location: LocationData) => void;
34
35
  export type ConnectionStateCallback = (state: ConnectionState) => void;
35
36
  export type MessageCallback = (message: string) => void;
37
+ export interface GeofenceRegion {
38
+ id: string;
39
+ latitude: number;
40
+ longitude: number;
41
+ radius: number;
42
+ notifyOnEntry: boolean;
43
+ notifyOnExit: boolean;
44
+ }
45
+ export type GeofenceEvent = 'enter' | 'exit';
46
+ export type GeofenceCallback = (event: GeofenceEvent, regionId: string) => void;
47
+ export interface SpeedConfig {
48
+ maxSpeedKmh: number;
49
+ minSpeedKmh: number;
50
+ checkIntervalMs: number;
51
+ }
52
+ export type SpeedAlertType = 'exceeded' | 'normalized' | 'below_minimum';
53
+ export type SpeedAlertCallback = (alert: SpeedAlertType, currentSpeedKmh: number) => void;
54
+ export interface TripStats {
55
+ distanceMeters: number;
56
+ durationMs: number;
57
+ averageSpeedKmh: number;
58
+ maxSpeedKmh: number;
59
+ pointCount: number;
60
+ }
61
+ export type LocationProviderStatus = 'enabled' | 'disabled';
62
+ export type ProviderStatusCallback = (gps: LocationProviderStatus, network: LocationProviderStatus) => void;
63
+ export type PermissionStatus = 'notDetermined' | 'denied' | 'restricted' | 'whenInUse' | 'always';
36
64
  export interface NitroLocationTracking extends HybridObject<{
37
65
  ios: 'swift';
38
66
  android: 'kotlin';
@@ -52,6 +80,22 @@ export interface NitroLocationTracking extends HybridObject<{
52
80
  onConnectionStateChange(callback: ConnectionStateCallback): void;
53
81
  onMessage(callback: MessageCallback): void;
54
82
  forceSync(): Promise<boolean>;
83
+ isFakeGpsEnabled(): boolean;
84
+ setRejectMockLocations(reject: boolean): void;
85
+ addGeofence(region: GeofenceRegion): void;
86
+ removeGeofence(regionId: string): void;
87
+ removeAllGeofences(): void;
88
+ onGeofenceEvent(callback: GeofenceCallback): void;
89
+ configureSpeedMonitor(config: SpeedConfig): void;
90
+ onSpeedAlert(callback: SpeedAlertCallback): void;
91
+ getCurrentSpeed(): number;
92
+ startTripCalculation(): void;
93
+ stopTripCalculation(): TripStats;
94
+ getTripStats(): TripStats;
95
+ resetTripCalculation(): void;
96
+ isLocationServicesEnabled(): boolean;
97
+ onProviderStatusChange(callback: ProviderStatusCallback): void;
98
+ getLocationPermissionStatus(): PermissionStatus;
55
99
  showLocalNotification(title: string, body: string): void;
56
100
  updateForegroundNotification(title: string, body: string): void;
57
101
  destroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"NitroLocationTracking.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationTracking.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAI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AM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAGhE,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -4,7 +4,7 @@ export default NitroLocationModule;
4
4
  export { requestLocationPermission } from './requestPermission';
5
5
  export { LocationSmoother } from './LocationSmoother';
6
6
  export { shortestRotation, calculateBearing } from './bearing';
7
- export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, } from './NitroLocationTracking.nitro';
7
+ export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, } from './NitroLocationTracking.nitro';
8
8
  export declare function useDriverLocation(config: LocationConfig): {
9
9
  location: LocationData | null;
10
10
  isMoving: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE/D,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// JFunc_void_GeofenceEvent_std__string.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "GeofenceEvent.hpp"
14
+ #include <string>
15
+ #include <functional>
16
+ #include <NitroModules/JNICallable.hpp>
17
+ #include "JGeofenceEvent.hpp"
18
+
19
+ namespace margelo::nitro::nitrolocationtracking {
20
+
21
+ using namespace facebook;
22
+
23
+ /**
24
+ * Represents the Java/Kotlin callback `(event: GeofenceEvent, regionId: String) -> Unit`.
25
+ * This can be passed around between C++ and Java/Kotlin.
26
+ */
27
+ struct JFunc_void_GeofenceEvent_std__string: public jni::JavaClass<JFunc_void_GeofenceEvent_std__string> {
28
+ public:
29
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_GeofenceEvent_std__string;";
30
+
31
+ public:
32
+ /**
33
+ * Invokes the function this `JFunc_void_GeofenceEvent_std__string` instance holds through JNI.
34
+ */
35
+ void invoke(GeofenceEvent event, const std::string& regionId) const {
36
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGeofenceEvent> /* event */, jni::alias_ref<jni::JString> /* regionId */)>("invoke");
37
+ method(self(), JGeofenceEvent::fromCpp(event), jni::make_jstring(regionId));
38
+ }
39
+ };
40
+
41
+ /**
42
+ * An implementation of Func_void_GeofenceEvent_std__string that is backed by a C++ implementation (using `std::function<...>`)
43
+ */
44
+ class JFunc_void_GeofenceEvent_std__string_cxx final: public jni::HybridClass<JFunc_void_GeofenceEvent_std__string_cxx, JFunc_void_GeofenceEvent_std__string> {
45
+ public:
46
+ static jni::local_ref<JFunc_void_GeofenceEvent_std__string::javaobject> fromCpp(const std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)>& func) {
47
+ return JFunc_void_GeofenceEvent_std__string_cxx::newObjectCxxArgs(func);
48
+ }
49
+
50
+ public:
51
+ /**
52
+ * Invokes the C++ `std::function<...>` this `JFunc_void_GeofenceEvent_std__string_cxx` instance holds.
53
+ */
54
+ void invoke_cxx(jni::alias_ref<JGeofenceEvent> event, jni::alias_ref<jni::JString> regionId) {
55
+ _func(event->toCpp(), regionId->toStdString());
56
+ }
57
+
58
+ public:
59
+ [[nodiscard]]
60
+ inline const std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)>& getFunction() const {
61
+ return _func;
62
+ }
63
+
64
+ public:
65
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_GeofenceEvent_std__string_cxx;";
66
+ static void registerNatives() {
67
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_GeofenceEvent_std__string_cxx::invoke_cxx)});
68
+ }
69
+
70
+ private:
71
+ explicit JFunc_void_GeofenceEvent_std__string_cxx(const std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)>& func): _func(func) { }
72
+
73
+ private:
74
+ friend HybridBase;
75
+ std::function<void(GeofenceEvent /* event */, const std::string& /* regionId */)> _func;
76
+ };
77
+
78
+ } // namespace margelo::nitro::nitrolocationtracking
@@ -14,6 +14,7 @@
14
14
  #include <functional>
15
15
  #include <NitroModules/JNICallable.hpp>
16
16
  #include "JLocationData.hpp"
17
+ #include <optional>
17
18
 
18
19
  namespace margelo::nitro::nitrolocationtracking {
19
20
 
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_LocationProviderStatus_LocationProviderStatus.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "LocationProviderStatus.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JLocationProviderStatus.hpp"
17
+
18
+ namespace margelo::nitro::nitrolocationtracking {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(gps: LocationProviderStatus, network: LocationProviderStatus) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_LocationProviderStatus_LocationProviderStatus: public jni::JavaClass<JFunc_void_LocationProviderStatus_LocationProviderStatus> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_LocationProviderStatus_LocationProviderStatus;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_LocationProviderStatus_LocationProviderStatus` instance holds through JNI.
33
+ */
34
+ void invoke(LocationProviderStatus gps, LocationProviderStatus network) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JLocationProviderStatus> /* gps */, jni::alias_ref<JLocationProviderStatus> /* network */)>("invoke");
36
+ method(self(), JLocationProviderStatus::fromCpp(gps), JLocationProviderStatus::fromCpp(network));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_LocationProviderStatus_LocationProviderStatus that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ class JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx final: public jni::HybridClass<JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx, JFunc_void_LocationProviderStatus_LocationProviderStatus> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_LocationProviderStatus_LocationProviderStatus::javaobject> fromCpp(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& func) {
46
+ return JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JLocationProviderStatus> gps, jni::alias_ref<JLocationProviderStatus> network) {
54
+ _func(gps->toCpp(), network->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolocationtracking/Func_void_LocationProviderStatus_LocationProviderStatus_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_LocationProviderStatus_LocationProviderStatus_cxx(const std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(LocationProviderStatus /* gps */, LocationProviderStatus /* network */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrolocationtracking