Commit e7442ca9 authored by Chris Scott's avatar Chris Scott

Avoid stopUpdatingLocation while modifying distanceFilter and power-cycling. ...

Avoid stopUpdatingLocation while modifying distanceFilter and power-cycling.  probably jumping at shadows while fighting through these new 7.1 issues
parent 6760a843
...@@ -206,6 +206,7 @@ ...@@ -206,6 +206,7 @@
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
} }
/** /**
* Change pace to moving/stopped * Change pace to moving/stopped
* @param {Boolean} isMoving * @param {Boolean} isMoving
...@@ -370,13 +371,13 @@ ...@@ -370,13 +371,13 @@
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{ {
NSLog(@"- CDVBackgroundGeoLocation locationManager failed: %@", error); NSLog(@"- CDVBackgroundGeoLocation locationManager failed: %@", error);
[locationManager stopUpdatingLocation];
isMoving = NO; isMoving = NO;
isAcquiringStationaryLocation = NO; isAcquiringStationaryLocation = NO;
stationaryLocation = nil; stationaryLocation = nil;
[locationManager startMonitoringSignificantLocationChanges]; [locationManager startMonitoringSignificantLocationChanges];
[locationManager stopUpdatingLocation];
} }
/** /**
...@@ -480,8 +481,6 @@ ...@@ -480,8 +481,6 @@
isAcquiringSpeed = NO; isAcquiringSpeed = NO;
locationAcquisitionAttempts = 0; locationAcquisitionAttempts = 0;
[locationManager stopUpdatingLocation];
// Kill the current stationary-region. // Kill the current stationary-region.
if (stationaryRegion != nil) { if (stationaryRegion != nil) {
[locationManager stopMonitoringForRegion:stationaryRegion]; [locationManager stopMonitoringForRegion:stationaryRegion];
...@@ -494,10 +493,11 @@ ...@@ -494,10 +493,11 @@
if (isMoving) { if (isMoving) {
isAcquiringSpeed = YES; isAcquiringSpeed = YES;
} else { } else {
// Crank up the GPS power temporarily to get a good fix on our current staionary location in order to set up region-monitoring.
isAcquiringStationaryLocation = YES; isAcquiringStationaryLocation = YES;
} }
if (isAcquiringSpeed || isAcquiringStationaryLocation) { if (isAcquiringSpeed || isAcquiringStationaryLocation) {
// Crank up the GPS power temporarily to get a good fix on our current location
[locationManager stopUpdatingLocation];
locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation]; [locationManager startUpdatingLocation];
...@@ -513,14 +513,15 @@ ...@@ -513,14 +513,15 @@
if (stationaryRegion != nil) { if (stationaryRegion != nil) {
[locationManager stopMonitoringForRegion:stationaryRegion]; [locationManager stopMonitoringForRegion:stationaryRegion];
} }
[locationManager stopUpdatingLocation];
locationManager.distanceFilter = distanceFilter;
locationManager.desiredAccuracy = desiredAccuracy;
[locationManager startMonitoringSignificantLocationChanges]; [locationManager startMonitoringSignificantLocationChanges];
stationaryRegion = [[CLCircularRegion alloc] initWithCenter: coord radius:stationaryRadius identifier:@"BackgroundGeoLocation stationary region"]; stationaryRegion = [[CLCircularRegion alloc] initWithCenter: coord radius:stationaryRadius identifier:@"BackgroundGeoLocation stationary region"];
stationaryRegion.notifyOnExit = YES; stationaryRegion.notifyOnExit = YES;
[locationManager startMonitoringForRegion:stationaryRegion]; [locationManager startMonitoringForRegion:stationaryRegion];
locationManager.distanceFilter = distanceFilter;
locationManager.desiredAccuracy = desiredAccuracy;
[locationManager stopUpdatingLocation];
} }
// If you don't stopMonitorying when application terminates, the app will be awoken still when a // If you don't stopMonitorying when application terminates, the app will be awoken still when a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment