From 5210a0531dc99612aeb6a9feddd00dd0caf2be1f Mon Sep 17 00:00:00 2001 From: Moritz Moeller Date: Tue, 29 Jan 2019 19:31:42 +0100 Subject: [PATCH] keep desiredAccuracy if observer is active --- Libraries/Geolocation/RCTLocationObserver.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 904538d8a64110..ce6df27105d6fe 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -355,7 +355,10 @@ - (void)locationManager:(CLLocationManager *)manager // Reset location accuracy if desiredAccuracy is changed. // Otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes. - if (ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) { + if (_observingLocation && ABS(_locationManager.desiredAccuracy - _observerOptions.accuracy) > 0.000001) { + _locationManager.desiredAccuracy = _observerOptions.accuracy; + } + if (!_observingLocation && ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) { _locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY; } }