My app monitors user location updates (not necessarily significant location change) with:
someLocationManager = [[CLLocationManager alloc] init];
[someLocationManager setDelegate:self];
[someLocationManager startUpdatingLocation];
When app (in simulator) is in foreground everything works ok, but when suspending it to background (not terminating), I get this error to the log:
Can't endBackgroundTask: no background task exists with identifier *, or it may have already been ended
All other answers for this error have no connection to location services, but only generic background task issues.
So it appears that the following 3 settings should be made in order for background location update to work properly. Do this and fix the problem:
NSLocationAlwaysUsageDescription
key is set (with value as a reason for the permission) ininfo.plist
.[someLocationManager requestAlwaysAuthorization];
when asking for permission.Location Updates
inBackground Modes
inCapabilities
section in your target settings. Not sure about this one, but sounds right.Enjoy!