Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didUpdateLocations not being called when app is in background

didUpdateLocations is working fine when app is active and running in foreground, but it stops to work as soon as app enters into background

In .h file

@property (nonatomic, strong) CLLocationManager *customerLocationManager;

in .m file

@synthesize customerLocationManager;



customerLocationManager = [[CLLocationManager alloc] init];
customerLocationManager.delegate = self;
customerLocationManager.desiredAccuracy = kCLLocationAccuracyBest;
customerLocationManager.distanceFilter = kCLDistanceFilterNone;

if(IS_OS_8_OR_LATER) {
    [customerLocationManager requestAlwaysAuthorization];
}
[customerLocationManager startUpdatingLocation];

I have integrated NSLocationAlwaysUsageDescription in info.plist. Background modes have been enabled and Location Updates option has been selected

like image 493
Kunal Babbar Avatar asked Nov 22 '15 16:11

Kunal Babbar


1 Answers

I have integrated NSLocationAlwaysUsageDescription in info.plist. Background modes have been enabled and Location Updates option has been selected

Good, but in iOS 9 there's a further requirement: you have to set the location manager's allowsBackgroundLocationUpdates to YES. You are not doing that, so you're not going to get background location updates.

like image 179
matt Avatar answered Oct 05 '22 14:10

matt