My application cannot determine lat / long coordinates via 3G in North America. It works great when connected to Wi-Fi. This is confirmed by both AT&T and Verizon with iOS 5. In the UK, it works as expected on both 3G and Wi-Fi with o2.
I really am a dead end as to what could be causing. I think my code is pretty simple in terms of accuracy, but since I'm on the other side of the pond, could I be aloof?
Are there any blatant errors in my code? (I removed some unrelated methods).
static NSTimeInterval MaxLocationAge = 60.0; // Seconds. static CLLocationAccuracy DesiredHorizontalAccuracy = 200.0; // Meters. static NSTimeInterval UpdateTimeout = 30.0; // Seconds. @implementation AFLocation @synthesize locationManager = _locationManager, delegate = _delegate, bestEffortAtLocation = _bestEffortAtLocation, updateStartedAt = _updateStartedAt; - (id)init { self = [super init]; if (self) { CLLocationManager *manager = [[CLLocationManager alloc] init]; self.locationManager = manager; [manager release]; self.locationManager.delegate = self; self.locationManager.distanceFilter = kCLDistanceFilterNone; self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation; } return self; } - (void)update { self.updateStartedAt = [NSDate date]; isUpdating = YES; [self.locationManager startUpdatingLocation]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if ([[NSDate date] timeIntervalSinceDate:self.updateStartedAt] > UpdateTimeout) { [self.locationManager stopUpdatingLocation]; if (isUpdating) { [self updateDidTimeout]; } isUpdating = NO; } NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; if (locationAge > MaxLocationAge) { return; } if (newLocation.horizontalAccuracy < 0) { return; } if (self.bestEffortAtLocation == nil || self.bestEffortAtLocation.horizontalAccuracy > newLocation.horizontalAccuracy) { self.bestEffortAtLocation = newLocation; if (newLocation.horizontalAccuracy <= DesiredHorizontalAccuracy) { self.bestEffortAtLocation = nil; isUpdating = NO; [self.locationManager stopUpdatingLocation]; [self didUpdateWithDesiredAccuracyToLocation:newLocation]; } } } @end
source share