Commit 0cc924a6 authored by Chris Scott's avatar Chris Scott

Define fetchCallbackId as @property instead of private variable

parent 54cee002
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#import <AudioToolbox/AudioToolbox.h> #import <AudioToolbox/AudioToolbox.h>
@interface CDVBackgroundGeoLocation : CDVPlugin <CLLocationManagerDelegate> @interface CDVBackgroundGeoLocation : CDVPlugin <CLLocationManagerDelegate>
@property (nonatomic, strong) NSString* syncCallbackId;
- (void) configure:(CDVInvokedUrlCommand*)command; - (void) configure:(CDVInvokedUrlCommand*)command;
- (void) start:(CDVInvokedUrlCommand*)command; - (void) start:(CDVInvokedUrlCommand*)command;
- (void) stop:(CDVInvokedUrlCommand*)command; - (void) stop:(CDVInvokedUrlCommand*)command;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
BOOL enabled; BOOL enabled;
NSString *token; NSString *token;
NSString *url; NSString *url;
NSString *syncCallbackId;
UIBackgroundTaskIdentifier bgTask; UIBackgroundTaskIdentifier bgTask;
NSTimer *backgroundTimer; NSTimer *backgroundTimer;
...@@ -39,10 +38,10 @@ ...@@ -39,10 +38,10 @@
BOOL isAcquiringStationaryLocation; BOOL isAcquiringStationaryLocation;
NSInteger maxStationaryLocationAttempts; NSInteger maxStationaryLocationAttempts;
BOOL isAcquiringSpeed; BOOL isAcquiringSpeed;
NSInteger maxSpeedAcquistionAttempts; NSInteger maxSpeedAcquistionAttempts;
NSInteger stationaryRadius; NSInteger stationaryRadius;
NSInteger distanceFilter; NSInteger distanceFilter;
NSInteger locationTimeout; NSInteger locationTimeout;
...@@ -83,7 +82,7 @@ ...@@ -83,7 +82,7 @@
// Params. // Params.
// 0 1 2 3 4 5 6 7 8 8 9 // 0 1 2 3 4 5 6 7 8 8 9
//[params, headers, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug, notificationTitle, notificationText, activityType] //[params, headers, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug, notificationTitle, notificationText, activityType]
// UNUSED ANDROID VARS // UNUSED ANDROID VARS
//params = [command.arguments objectAtIndex: 0]; //params = [command.arguments objectAtIndex: 0];
//headers = [command.arguments objectAtIndex: 1]; //headers = [command.arguments objectAtIndex: 1];
...@@ -94,9 +93,9 @@ ...@@ -94,9 +93,9 @@
desiredAccuracy = [self decodeDesiredAccuracy:[[command.arguments objectAtIndex: 6] intValue]]; desiredAccuracy = [self decodeDesiredAccuracy:[[command.arguments objectAtIndex: 6] intValue]];
isDebugging = [[command.arguments objectAtIndex: 7] boolValue]; isDebugging = [[command.arguments objectAtIndex: 7] boolValue];
activityType = [self decodeActivityType:[command.arguments objectAtIndex:9]]; activityType = [self decodeActivityType:[command.arguments objectAtIndex:9]];
syncCallbackId = command.callbackId; self.syncCallbackId = command.callbackId;
locationManager.activityType = activityType; locationManager.activityType = activityType;
locationManager.pausesLocationUpdatesAutomatically = YES; locationManager.pausesLocationUpdatesAutomatically = YES;
locationManager.distanceFilter = distanceFilter; // meters locationManager.distanceFilter = distanceFilter; // meters
...@@ -356,7 +355,7 @@ ...@@ -356,7 +355,7 @@
[locationManager startUpdatingLocation]; [locationManager startUpdatingLocation];
} }
} }
// Bail out if there's already a background-task in-effect. // Bail out if there's already a background-task in-effect.
if (bgTask != UIBackgroundTaskInvalid) { if (bgTask != UIBackgroundTaskInvalid) {
NSLog(@" Abort: found existing background-task"); NSLog(@" Abort: found existing background-task");
...@@ -379,7 +378,7 @@ ...@@ -379,7 +378,7 @@
isMoving = NO; isMoving = NO;
isAcquiringStationaryLocation = NO; isAcquiringStationaryLocation = NO;
stationaryLocation = nil; stationaryLocation = nil;
[locationManager startMonitoringSignificantLocationChanges]; [locationManager startMonitoringSignificantLocationChanges];
[locationManager stopUpdatingLocation]; [locationManager stopUpdatingLocation];
} }
...@@ -427,7 +426,7 @@ ...@@ -427,7 +426,7 @@
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo]; result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
[result setKeepCallbackAsBool:YES]; [result setKeepCallbackAsBool:YES];
[self.commandDelegate sendPluginResult:result callbackId:syncCallbackId]; [self.commandDelegate sendPluginResult:result callbackId:self.syncCallbackId];
} }
- (void) stopBackgroundTask - (void) stopBackgroundTask
...@@ -479,7 +478,7 @@ ...@@ -479,7 +478,7 @@
- (void)setPace:(BOOL)value - (void)setPace:(BOOL)value
{ {
NSLog(@"- CDVBackgroundGeoLocation setPace %d, stationaryRegion? %d", value, stationaryRegion!=nil); NSLog(@"- CDVBackgroundGeoLocation setPace %d, stationaryRegion? %d", value, stationaryRegion!=nil);
isMoving = value; isMoving = value;
isAcquiringStationaryLocation = NO; isAcquiringStationaryLocation = NO;
isAcquiringSpeed = NO; isAcquiringSpeed = NO;
...@@ -496,12 +495,6 @@ ...@@ -496,12 +495,6 @@
} }
if (isMoving) { if (isMoving) {
isAcquiringSpeed = YES; isAcquiringSpeed = YES;
locationAcquisitionAttempts = 0;
locationManager.distanceFilter = distanceFilter;
// Power-up the GPS temporarily until we get a good speed sample.
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
} else { } else {
isAcquiringStationaryLocation = YES; isAcquiringStationaryLocation = YES;
} }
......
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