Skip to content
Permalink
Browse files
  • Loading branch information
purplecabbage committed Apr 25, 2016
2 parents b298182 + 8fbceca commit f148399906284d6a08cbe6d4006914be2dbcda60
Showing 1 changed file with 28 additions and 26 deletions.
@@ -192,35 +192,37 @@ - (void)locationManager:(CLLocationManager*)manager

- (void)getLocation:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];

if ([self isLocationServicesEnabled] == NO) {
NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
[posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
[posError setObject:@"Location services are disabled." forKey:@"message"];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
} else {
if (!self.locationData) {
self.locationData = [[CDVLocationData alloc] init];
}
CDVLocationData* lData = self.locationData;
if (!lData.locationCallbacks) {
lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
}
[self.commandDelegate runInBackground:^{
NSString* callbackId = command.callbackId;
BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue];

if ([self isLocationServicesEnabled] == NO) {
NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
[posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
[posError setObject:@"Location services are disabled." forKey:@"message"];
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
[self.commandDelegate sendPluginResult:result callbackId:callbackId];
} else {
if (!self.locationData) {
self.locationData = [[CDVLocationData alloc] init];
}
CDVLocationData* lData = self.locationData;
if (!lData.locationCallbacks) {
lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
}

if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
// add the callbackId into the array so we can call back when get data
if (callbackId != nil) {
[lData.locationCallbacks addObject:callbackId];
if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
// add the callbackId into the array so we can call back when get data
if (callbackId != nil) {
[lData.locationCallbacks addObject:callbackId];
}
// Tell the location manager to start notifying us of heading updates
[self startLocation:enableHighAccuracy];
} else {
[self returnLocationInfo:callbackId andKeepCallback:NO];
}
// Tell the location manager to start notifying us of heading updates
[self startLocation:enableHighAccuracy];
} else {
[self returnLocationInfo:callbackId andKeepCallback:NO];
}
}
}];
}

- (void)addWatch:(CDVInvokedUrlCommand*)command

0 comments on commit f148399

Please sign in to comment.