5

MKMapview current user location not fire in iOS-8,previous iOS-7 & iOS-6 are working fine.

     self.mapView.delegate = self;
     self.mapView.showsUserLocation =YES; 

In this line to call automatically the user current location delegate methods

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
}

but it not fire in iOS-8.

Darshan Kunjadiya
  • 3,323
  • 1
  • 29
  • 31
user1418679
  • 51
  • 1
  • 2
  • possible duplicate of [iOS 8 : Location Services not working](http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working) – Adrian Toman Sep 20 '14 at 00:50

3 Answers3

6

In iOS8, you need to request user's authorization before getting their location.

There are two kinds of request:

-[CLLocationManager requestWhenInUseAuthorization] lets you get users' location only when the app is awaken.

-[CLLocationManager requestAlwaysAuthorization] lets you get users' location even when it's in the background.

You can choose between them accordingly.

For example, put this before you start updating location:

// ask for authorization
CLLocationManager * locationManager = [[CLLocationManager alloc] init];
// check before requesting, otherwise it might crash in older version
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { 

     [locationManager requestWhenInUseAuthorization];

}

Furthermore, don't forget to add two keys

NSLocationWhenInUseUsageDescription

and

NSLocationAlwaysUsageDescription

into your info.plist.

Leave the values empty to use the default messages or you can customize your own by inputting the values.

Tim Chen
  • 1,364
  • 12
  • 14
3

In ios 8 Authorization is required as below

    NSString * osVersion = [[UIDevice currentDevice] systemVersion];
    if ([osVersion floatValue]>= 8.0 ) {
    [_CLLocationManager requestAlwaysAuthorization]; //Requests permission to use location services whenever the app is running. 
// [_CLLocationManager requestWhenInUseAuthorization]; //Requests permission to use location services while the app is in the foreground. 
    }
    [_CLLocationManager startUpdatingLocation];

And you need to add two keys in the plist

1.NSLocationAlwaysUsageDescription

2.NSLocationWhenInUseUsageDescription

enter image description here

Ramesh Muthe
  • 811
  • 7
  • 15
0

In iOS 8 Mapview Current Location fire using

You can set in your .plist file

<key>NSLocationWhenInUseUsageDescription</key>
<string>Your app name Or Other string</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Your app name Or Other string</string>

And your code side you just implement this

CLLocationManager * locationmanager = [CLLocationManager new];

locationmanager.delegate = self;
locationmanager.distanceFilter = kCLDistanceFilterNone;
locationmanager.desiredAccuracy = kCLLocationAccuracyBest;
[locationmanager startUpdatingLocation];    
[locationmanager requestAlwaysAuthorization];

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {

location = [locations objectAtIndex:0];
[locationmanager stopUpdatingLocation];

}

I am using this my app get perfect current location.