-1

I am using the below code for displaying the user current location in iOS 8.4.

- (void)viewDidLoad 
    {        
         [super viewDidLoad];

         [locationManager requestAlwaysAuthorization];
         self.mapView.delegate = self;
         [self.mapView setShowsUserLocation:YES];
         locationManager = [[CLLocationManager alloc] init];
         locationManager setDelegate:self];
         [locationManager setDistanceFilter:kCLDistanceFilterNone];
         [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    }

But it is not working properly. It displays the following error:

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

Rumin
  • 3,787
  • 3
  • 27
  • 30
Birendra
  • 623
  • 1
  • 5
  • 17
  • Possible duplicate of [iOS 8 requestWhenInUseAuthorization no Popup](http://stackoverflow.com/questions/24850128/ios-8-requestwheninuseauthorization-no-popup) – Kosuke Ogawa Oct 31 '15 at 08:18

1 Answers1

0

For get user current location you need add one key as string in your project info.plist file.

Key is : NSLocationAlwaysUsageDescription

Maulik Patel
  • 397
  • 4
  • 15