react-native-nitro-geolocation 1.3.0 → 1.3.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/README.md CHANGED
@@ -179,7 +179,39 @@ permission set from the Android background setup guide when using
179
179
 
180
180
  ---
181
181
 
182
- ### 4. Continue In The Docs
182
+ ### 4. DevTools Plugin
183
+
184
+ Use the Rozenite DevTools plugin to mock locations during development with an
185
+ interactive map. It works with the Modern API root import.
186
+
187
+ ![DevTools Plugin Demo](https://raw.githubusercontent.com/jingjing2222/react-native-nitro-geolocation/main/devtools.gif)
188
+
189
+ ```bash
190
+ yarn add @react-native-nitro-geolocation/rozenite-plugin
191
+ ```
192
+
193
+ ```tsx
194
+ import {
195
+ createPosition,
196
+ useGeolocationDevTools,
197
+ } from "@react-native-nitro-geolocation/rozenite-plugin";
198
+
199
+ function App() {
200
+ useGeolocationDevTools({
201
+ initialPosition: createPosition("Seoul, South Korea"),
202
+ });
203
+
204
+ return <RootNavigator />;
205
+ }
206
+ ```
207
+
208
+ The plugin requires Rozenite DevTools in your app. See the
209
+ [DevTools Plugin guide](https://react-native-nitro-geolocation.pages.dev/guide/devtools)
210
+ for setup, presets, troubleshooting, and the demo.
211
+
212
+ ---
213
+
214
+ ### 5. Continue In The Docs
183
215
 
184
216
  Use the docs site for the detailed flows:
185
217
 
@@ -116,9 +116,10 @@ class NitroGeolocation(
116
116
  success: (PermissionStatus) -> Unit,
117
117
  error: ((LocationError) -> Unit)?
118
118
  ): Unit {
119
- // Check if already determined
119
+ // Android reports missing location permission as DENIED even before a
120
+ // runtime prompt has been shown, so denied must still request.
120
121
  val currentStatus = getCurrentPermissionStatus()
121
- if (currentStatus != PermissionStatus.UNDETERMINED) {
122
+ if (currentStatus == PermissionStatus.GRANTED) {
122
123
  success(currentStatus)
123
124
  return
124
125
  }
@@ -100,7 +100,8 @@ class NitroBackgroundLocationController private constructor(
100
100
  if (permissions.foregroundPermission() != PermissionStatus.GRANTED) {
101
101
  throw SecurityException("Foreground location permission is required")
102
102
  }
103
- if (permissions.backgroundPermission() != BackgroundPermissionStatus.GRANTED) {
103
+ if (current.android?.foregroundService == null &&
104
+ permissions.backgroundPermission() != BackgroundPermissionStatus.GRANTED) {
104
105
  throw SecurityException("Background location permission is required")
105
106
  }
106
107
  state = BackgroundLocationState.STARTING
@@ -23,6 +23,7 @@ class NitroBackgroundLocation: HybridNitroBackgroundLocationSpec {
23
23
  private var delegate: NitroBackgroundLocationDelegate?
24
24
  private let motionManager = CMMotionActivityManager()
25
25
  private let motionQueue = OperationQueue()
26
+ private var isMotionUpdatesRunning = false
26
27
  private let syncQueue = DispatchQueue(label: "nitro.background.sync")
27
28
  private let httpSync = IOSBackgroundHttpSync()
28
29
  private var permissionSemaphore: DispatchSemaphore?
@@ -114,7 +115,7 @@ class NitroBackgroundLocation: HybridNitroBackgroundLocationSpec {
114
115
  self.manager?.stopUpdatingLocation()
115
116
  self.manager?.stopMonitoringSignificantLocationChanges()
116
117
  }
117
- self.motionManager.stopActivityUpdates()
118
+ self.stopMotionUpdatesIfRunning()
118
119
  self.isRunning = false
119
120
  self.state = .stopped
120
121
  }
@@ -128,7 +129,7 @@ class NitroBackgroundLocation: HybridNitroBackgroundLocationSpec {
128
129
  self.manager?.stopMonitoringSignificantLocationChanges()
129
130
  self.manager?.monitoredRegions.forEach { self.manager?.stopMonitoring(for: $0) }
130
131
  }
131
- self.motionManager.stopActivityUpdates()
132
+ self.stopMotionUpdatesIfRunning()
132
133
  self.options = nil
133
134
  self.defaults.removeObject(forKey: self.optionsKey)
134
135
  self.isRunning = false
@@ -376,7 +377,7 @@ class NitroBackgroundLocation: HybridNitroBackgroundLocationSpec {
376
377
 
377
378
  func stopActivityRecognition() throws -> Promise<Void> {
378
379
  return Promise.async {
379
- self.motionManager.stopActivityUpdates()
380
+ self.stopMotionUpdatesIfRunning()
380
381
  }
381
382
  }
382
383
 
@@ -496,6 +497,13 @@ class NitroBackgroundLocation: HybridNitroBackgroundLocationSpec {
496
497
  guard let self, let activity else { return }
497
498
  self.handleMotionActivity(activity)
498
499
  }
500
+ isMotionUpdatesRunning = true
501
+ }
502
+
503
+ private func stopMotionUpdatesIfRunning() {
504
+ guard isMotionUpdatesRunning else { return }
505
+ motionManager.stopActivityUpdates()
506
+ isMotionUpdatesRunning = false
499
507
  }
500
508
 
501
509
  private func handleMotionActivity(_ activity: CMMotionActivity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-geolocation",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Nitro-powered native geolocation for modern React Native apps",
5
5
  "main": "src/index",
6
6
  "source": "src/index",