0

didUpdateLocations is never called, instead didFailWithError is called with denied code kCLErrorDenied. Here are the things that i did:

#import "ViewController.h"
@import CoreLocation;

@interface ViewController () <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager *locationManager;
@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    self.locationManager = [[CLLocationManager alloc] init];

    self.locationManager.delegate = self;

    // Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.

    if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {

        [self.locationManager requestWhenInUseAuthorization];

    }

    [self.locationManager startUpdatingLocation];
}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations

{

    NSLog(@"update");

}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(nonnull NSError *)error

{

    NSLog(@"error");
}

@end

Inserted NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription to the info.plist of the app. Enabled Background Modes in Capabilities with Location updates selected. Get help from the very famous blog post. I receive Location Access Request popup and allow the app to access location.

But i couldnt managed to get location updates. It works in IPAD with IOS 8 but not work at ipad with IOS version 9.3.2. How can i make location updates work in IOS 9.3.2?

Murat
  • 3,084
  • 37
  • 55

1 Answers1

0

trying following thing may resolve your issue:

  • go to settings and reset your location services
  • reset your network settings
  • restarting the simulator

also, if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but don't have a default location set.

Add NSLocationAlwaysUsageDescription to your plist as type string if using Always authorization. Also, do the same for NSLocationWhenInUseUsageDescription same way if using WhenInUse authorization.

For detail check answers here:

didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

and IOS 9 Error Domain=kCLErrorDomain Code=0 "(null)"

Community
  • 1
  • 1
Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51
  • I am using a real device for debugging. It works with Allow Location Simulation on simulator but not in the real device. I added NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription to plist as mentioned in my question. I read nearly every stackoverflow post, but couldnt find a solution. I applied the things you said but not working. – Murat Jun 22 '16 at 14:20