react-native-nitro-geolocation 1.3.1 → 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.
|
@@ -116,9 +116,10 @@ class NitroGeolocation(
|
|
|
116
116
|
success: (PermissionStatus) -> Unit,
|
|
117
117
|
error: ((LocationError) -> Unit)?
|
|
118
118
|
): Unit {
|
|
119
|
-
//
|
|
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
|
|
122
|
+
if (currentStatus == PermissionStatus.GRANTED) {
|
|
122
123
|
success(currentStatus)
|
|
123
124
|
return
|
|
124
125
|
}
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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) {
|