Skip to content

Commit bbcb97a

Browse files
omnikronfacebook-github-bot
authored andcommitted
Location Services: don't reset desiredAccuracy on every update/error (#23209)
Summary: See #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](705a8e0) 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: #23209 Differential Revision: D13879497 Pulled By: cpojer fbshipit-source-id: f3c6c9c5ef698b23b99c407fd764ac990d69bf8c
1 parent 4c10f93 commit bbcb97a

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

Libraries/Geolocation/RCTLocationObserver.m

-10
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,6 @@ - (void)locationManager:(CLLocationManager *)manager
353353
[_locationManager stopUpdatingLocation];
354354
}
355355

356-
// Reset location accuracy if desiredAccuracy is changed.
357-
// Otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes.
358-
if (ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) {
359-
_locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY;
360-
}
361356
}
362357

363358
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
@@ -389,11 +384,6 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
389384
}
390385
[_pendingRequests removeAllObjects];
391386

392-
// Reset location accuracy if desiredAccuracy is changed.
393-
// Otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes.
394-
if (ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) {
395-
_locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY;
396-
}
397387
}
398388

399389
static void checkLocationConfig()

0 commit comments

Comments
 (0)