Commit d8370c35 authored by Chris Scott's avatar Chris Scott

Uhoh, having app crashes when we try to modify current CLLocationManager...

Uhoh, having app crashes when we try to modify current CLLocationManager settings by stopping/starting.  setConfig merely sets instance vars.  settings take effect only after the natural progression of Location events
parent c5a1bf52
...@@ -99,12 +99,7 @@ ...@@ -99,12 +99,7 @@
locationTimeout = [config[@"timeout"] intValue]; locationTimeout = [config[@"timeout"] intValue];
NSLog(@" locationTimeout: %@", config[@"timeout"]); NSLog(@" locationTimeout: %@", config[@"timeout"]);
} }
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (enabled && state == UIApplicationStateBackground) {
[self setPace:isMoving];
}
CDVPluginResult* result = nil; CDVPluginResult* result = nil;
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
...@@ -175,7 +170,7 @@ ...@@ -175,7 +170,7 @@
*/ */
-(void) onSuspend:(NSNotification *) notification -(void) onSuspend:(NSNotification *) notification
{ {
NSLog(@"- CDVBackgroundGeoLocation suspend"); NSLog(@"- CDVBackgroundGeoLocation suspend (%hhd)", enabled);
suspendedAt = [NSDate date]; suspendedAt = [NSDate date];
if (enabled) { if (enabled) {
...@@ -334,13 +329,16 @@ ...@@ -334,13 +329,16 @@
* Creates a new circle around user and region-monitors it for exit * Creates a new circle around user and region-monitors it for exit
*/ */
- (void) startMonitoringStationaryRegion { - (void) startMonitoringStationaryRegion {
NSLog(@"- CDVBackgroundGeoLocation createStationaryRegion"); NSInteger radius = (stationaryRadius>0) ? stationaryRadius : 1;
CLLocationCoordinate2D coord = [[locationManager location] coordinate];
NSLog(@"- CDVBackgroundGeoLocation createStationaryRegion (%f, %f)", coord.latitude, coord.longitude);
if (myRegion != nil) { if (myRegion != nil) {
[locationManager stopMonitoringForRegion:myRegion]; [locationManager stopMonitoringForRegion:myRegion];
} }
NSInteger radius = (stationaryRadius>0) ? stationaryRadius : 1;
myRegion = [[CLCircularRegion alloc] initWithCenter: [[locationManager location] coordinate] radius:radius identifier:@"BackgroundGeoLocation stationary region"]; myRegion = [[CLCircularRegion alloc] initWithCenter:coord radius:radius identifier:@"BackgroundGeoLocation stationary region"];
myRegion.notifyOnExit = YES; myRegion.notifyOnExit = YES;
[locationManager startMonitoringForRegion:myRegion]; [locationManager startMonitoringForRegion:myRegion];
} }
......
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