Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix distanceFilter caching for LocationObserver #6987

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Libraries/Geolocation/RCTLocationObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ - (dispatch_queue_t)methodQueue

#pragma mark - Private API

- (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy

- (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy distanceFilter:(CLLocationDistance)distanceFilter
{
if (!_locationManager) {
_locationManager = [CLLocationManager new];
_locationManager.distanceFilter = _observerOptions.distanceFilter;
_locationManager.delegate = self;
}

Expand All @@ -147,6 +147,7 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur
[_locationManager requestWhenInUseAuthorization];
}

_locationManager.distanceFilter = distanceFilter;
_locationManager.desiredAccuracy = desiredAccuracy;
// Start observing location
[_locationManager startUpdatingLocation];
Expand Down Expand Up @@ -179,7 +180,7 @@ - (void)timeout:(NSTimer *)timer
_observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy);
}

[self beginLocationUpdatesWithDesiredAccuracy:_observerOptions.accuracy];
[self beginLocationUpdatesWithDesiredAccuracy:_observerOptions.accuracy distanceFilter:_observerOptions.distanceFilter];
_observingLocation = YES;
}

Expand Down Expand Up @@ -253,7 +254,7 @@ - (void)timeout:(NSTimer *)timer
if (_locationManager) {
accuracy = MIN(_locationManager.desiredAccuracy, accuracy);
}
[self beginLocationUpdatesWithDesiredAccuracy:accuracy];
[self beginLocationUpdatesWithDesiredAccuracy:accuracy distanceFilter:options.distanceFilter];
}

#pragma mark - CLLocationManagerDelegate
Expand Down