2

I am using following code to update location - it works fine below iOS 9 but in iOS 9 getting error -

   locationManager = [[CLLocationManager alloc] init];
   [locationManager setDelegate:self];
   [locationManager setDistanceFilter:kCLDistanceFilterNone];
   [locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];

   if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
      [locationManager requestWhenInUseAuthorization];

 // tried this also - 
      /* if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
  locationManager.allowsBackgroundLocationUpdates = YES;}*/
       [locationManager requestLocation];

didFailWithError: Error Domain=kCLErrorDomain Code=0 "(null)"

Also done change in plist file -

enter image description here

Anyone can suggest what I am missing ?

San007
  • 762
  • 1
  • 9
  • 30
  • please check: http://stackoverflow.com/questions/30808192/allowsbackgroundlocationupdates-in-cllocationmanager-in-ios9 – xGoPox Sep 01 '15 at 12:37
  • @San007 Do u find any solution for this. I'm getting this problem in iPads only, its working in iPhone. – siva krishna Oct 27 '15 at 10:33
  • I am also facing d same problem,,,did u find d solution –  Sep 30 '16 at 13:47

3 Answers3

2

This error was also rising for me when location requirement keys are not added to Info.plist.

Check if you have one of these keys (with Bool values) in your Info.plist:

NSLocationWhenInUseUsageDescription 
NSLocationAlwaysUsageDescription
Eugene Dudnyk
  • 5,553
  • 1
  • 23
  • 48
0
  • Please reset your network settings
  • Reset your location services
  • Check that the WiFi or 3G work
  • Another is when Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set.
0

As suggested by @Pasha_Molodkin, I would suggest that you try this out (common bug when no default location provided) :

my answer to a similar post

In short :

  • Product -> Scheme -> Edit Scheme -> Options -> Allow Location Simulation must be checked and try providing a default location, don't leave it set to "none"
Community
  • 1
  • 1
H4Hugo
  • 2,570
  • 3
  • 16
  • 32