mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
fix watchPosition keep updating location
Reviewed By: @nicklockwood Differential Revision: D2519624 fb-gh-sync-id: 7366c5ac9e06082448b9fbba3c616aaf8e4183f9
This commit is contained in:
parent
da359c312a
commit
aacd2d90a4
@ -284,8 +284,11 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
||||
[_locationManager stopUpdatingLocation];
|
||||
}
|
||||
|
||||
// Reset location accuracy
|
||||
_locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY;
|
||||
// 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
|
||||
@ -318,8 +321,11 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
||||
}
|
||||
[_pendingRequests removeAllObjects];
|
||||
|
||||
// Reset location accuracy
|
||||
_locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY;
|
||||
// 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)checkLocationConfig
|
||||
|
Loading…
x
Reference in New Issue
Block a user