fix watchPosition keep updating location

Reviewed By: @nicklockwood

Differential Revision: D2519624

fb-gh-sync-id: 7366c5ac9e06082448b9fbba3c616aaf8e4183f9
This commit is contained in:
Jiajie Zhu 2015-10-12 11:54:30 -07:00 committed by facebook-github-bot-7
parent da359c312a
commit aacd2d90a4

View File

@ -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