I have several GPS apps all of which allow third-party devices such as the Dual 150 and 160 GPS receivers as well as Apple’s built-in GPS receiver. Since continuous distance measurements are critical down to 5 feet or less when driving either fast or slow, I force the apps to require background modes for Location Updates, External Accessory Communication, and Uses Bluetooth LE Accessories.
In addition to computing distances at sampling rates ranging from 1 to 10 times per second, I also use MKOverlayRenderer and MKPolyline on a mapView to display the track on a map whenever the car has moved to a new location.
I am using Xcode 8.1 and iOS 10.1 for testing on iPhones and iPads. Everything works as expected on the Simulator, but on the iPhone and iPad devices themselves, the Apple GPS background signals are not updating while the Dual GPS background signals are fine. The foreground functioning is the same and accurate, however.
Strangely, background mode works perfectly with the Dual GPS Receivers in the real world but fails spectacularly when having to rely on Apple’s GPS receiver. When the apps are active, again in the real world, the distances and the tracking are perfectly computed and displayed whether using the Duals or the Apple internal GPS.
When using the Apple GPS the track and distance show properly, then I touch the home button and put the app into background mode for a short while. When I return to active mode, the distance is too short and the track shows as a straight line from the point at which I entered background mode to the point where the app returns to active mode.
Needless to say, I expect the background location distances and tracking to work regardless of whether the iPhone or iPad is using Apple’s GPS or some third-party input. But, clearly that is not the case.
Is there some problem with background location when both distance and rendering are demanded by the app? If so, why should it work correctly with a third-party device but not with Apple’s own built-in GPS device. Very, very strange.
Any ideas would be most appreciated. Thanks.
Here is some of my code:
-
(void)viewDidLoad {
[super viewDidLoad];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.allowsBackgroundLocationUpdates = YES;
_locationManager.pausesLocationUpdatesAutomatically = NO;
_locationManager.activityType = CLActivityTypeAutomotiveNavigation;
if ([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[_locationManager requestAlwaysAuthorization]; }