Commit f98e253e authored by Chris Scott's avatar Chris Scott

setPace to current value of isMoving rather than hard-coded NO

parent 403db190
...@@ -81,12 +81,12 @@ ...@@ -81,12 +81,12 @@
*/ */
- (void) start:(CDVInvokedUrlCommand*)command - (void) start:(CDVInvokedUrlCommand*)command
{ {
NSLog(@"CDVBackgroundGeoLocation start"); NSLog(@"- CDVBackgroundGeoLocation start");
enabled = YES; enabled = YES;
UIApplicationState state = [[UIApplication sharedApplication] applicationState]; UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateBackground) { if (state == UIApplicationStateBackground) {
[self setPace:NO]; [self setPace:isMoving];
} }
} }
/** /**
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
*/ */
- (void) stop:(CDVInvokedUrlCommand*)command - (void) stop:(CDVInvokedUrlCommand*)command
{ {
NSLog(@"CDVBackgroundGeoLocation stop"); NSLog(@"- CDVBackgroundGeoLocation stop");
enabled = NO; enabled = NO;
[locationManager stopUpdatingLocation]; [locationManager stopUpdatingLocation];
[locationManager stopMonitoringSignificantLocationChanges]; [locationManager stopMonitoringSignificantLocationChanges];
...@@ -102,12 +102,12 @@ ...@@ -102,12 +102,12 @@
} }
- (void) test:(CDVInvokedUrlCommand*)command - (void) test:(CDVInvokedUrlCommand*)command
{ {
NSLog(@"CDVBackgroundGeoLocation test"); NSLog(@"- CDVBackgroundGeoLocation test");
[locationManager startMonitoringSignificantLocationChanges]; [locationManager startMonitoringSignificantLocationChanges];
if ([locationCache count] > 0){ if ([locationCache count] > 0){
[self sync]; [self sync];
} else { } else {
NSLog(@"CDVBackgroundGeoLocation could not find a location to sync"); NSLog(@"- CDVBackgroundGeoLocation could not find a location to sync");
} }
} }
/** /**
...@@ -118,14 +118,18 @@ ...@@ -118,14 +118,18 @@
{ {
isMoving = [[command.arguments objectAtIndex: 0] boolValue]; isMoving = [[command.arguments objectAtIndex: 0] boolValue];
NSLog(@"- CDVBackgroundGeoLocation onPaceChange %hhd", isMoving); NSLog(@"- CDVBackgroundGeoLocation onPaceChange %hhd", isMoving);
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateBackground) {
[self setPace:isMoving]; [self setPace:isMoving];
}
} }
/** /**
* Called by js to signify the end of a background-geolocation event * Called by js to signify the end of a background-geolocation event
*/ */
-(void) finish:(CDVInvokedUrlCommand*)command -(void) finish:(CDVInvokedUrlCommand*)command
{ {
NSLog(@"CDVBackgroundGeoLocation finish"); NSLog(@"- CDVBackgroundGeoLocation finish");
[self stopBackgroundTask]; [self stopBackgroundTask];
} }
...@@ -134,7 +138,7 @@ ...@@ -134,7 +138,7 @@
*/ */
-(void) onSuspend:(NSNotification *) notification -(void) onSuspend:(NSNotification *) notification
{ {
NSLog(@"CDVBackgroundGeoLocation suspend"); NSLog(@"- CDVBackgroundGeoLocation suspend");
suspendedAt = [NSDate date]; suspendedAt = [NSDate date];
if (enabled && !isMoving) { if (enabled && !isMoving) {
...@@ -146,7 +150,7 @@ ...@@ -146,7 +150,7 @@
*/ */
-(void) onResume:(NSNotification *) notification -(void) onResume:(NSNotification *) notification
{ {
NSLog(@"CDVBackgroundGeoLocation resume"); NSLog(@"- CDVBackgroundGeoLocation resume");
if (enabled) { if (enabled) {
[locationManager stopMonitoringSignificantLocationChanges]; [locationManager stopMonitoringSignificantLocationChanges];
[locationManager stopUpdatingLocation]; [locationManager stopUpdatingLocation];
...@@ -159,7 +163,7 @@ ...@@ -159,7 +163,7 @@
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations -(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{ {
NSLog(@"CDVBackgroundGeoLocation didUpdateLocations"); NSLog(@"- CDVBackgroundGeoLocation didUpdateLocations");
// Handle location updates as normal, code omitted for brevity. // Handle location updates as normal, code omitted for brevity.
// The omitted code should determine whether to reject the location update for being too // The omitted code should determine whether to reject the location update for being too
...@@ -227,10 +231,9 @@ ...@@ -227,10 +231,9 @@
backgroundTimer = nil; backgroundTimer = nil;
UIApplication *app = [UIApplication sharedApplication]; UIApplication *app = [UIApplication sharedApplication];
NSLog(@"CDVBackgroundGeoLocation stopBackgroundTask (remaining t: %f)", app.backgroundTimeRemaining); NSLog(@"- CDVBackgroundGeoLocation stopBackgroundTask (remaining t: %f)", app.backgroundTimeRemaining);
if (bgTask != UIBackgroundTaskInvalid) if (bgTask != UIBackgroundTaskInvalid)
{ {
NSLog(@" -bgTask killed");
[[UIApplication sharedApplication] endBackgroundTask:bgTask]; [[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid; bgTask = UIBackgroundTaskInvalid;
} }
...@@ -289,7 +292,7 @@ ...@@ -289,7 +292,7 @@
* 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"); NSLog(@"- CDVBackgroundGeoLocation createStationaryRegion");
if (myRegion != nil) { if (myRegion != nil) {
[locationManager stopMonitoringForRegion:myRegion]; [locationManager stopMonitoringForRegion: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