From bbcb97a29adc2a3a05728b47d28e28fa78d84df2 Mon Sep 17 00:00:00 2001 From: Oli Barnett Date: Wed, 30 Jan 2019 10:02:36 -0800 Subject: [PATCH] Location Services: don't reset desiredAccuracy on every update/error (#23209) Summary: See https://github.com/facebook/react-native/issues/7680. On iOS the RCTLocationObserver delegate is overriding `desiredAccuracy` every time CLLocationManager calls `didUpdateLocations` or `didFailWithError`. `desiredAccuracy` is reset to `RCT_DEFAULT_LOCATION_ACCURACY` (100 meters) This effectively makes it impossible for a react-native app to use any location accuracy other than the default. This commit simply removes the code which resets the desired accuracy, as there seems to be no rationale for doing so. The reset code was added as part of [a large general change](https://github.com/facebook/react-native/commit/705a8e0144775ff695f26a1f6b41d0baa6bed683) so the original intention is unclear from the history. If somebody can explain it to me, I'm happy to rework this PR accordingly. Changelog: ---------- [iOS] [Fixed] - Location Services accuracy constantly reset to default of 100 meters. Pull Request resolved: https://github.com/facebook/react-native/pull/23209 Differential Revision: D13879497 Pulled By: cpojer fbshipit-source-id: f3c6c9c5ef698b23b99c407fd764ac990d69bf8c --- Libraries/Geolocation/RCTLocationObserver.m | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 904538d8a64110..09cec2b3ff53e9 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -353,11 +353,6 @@ - (void)locationManager:(CLLocationManager *)manager [_locationManager stopUpdatingLocation]; } - // 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) { - _locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY; - } } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error @@ -389,11 +384,6 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError * } [_pendingRequests removeAllObjects]; - // 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) { - _locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY; - } } static void checkLocationConfig()