Here is my code :
if (!_locationManager)
{
_locationManager = [[CLLocationManager alloc] init];
[_locationManager setDelegate:self];
}
[_locationManager startUpdatingLocation];
please help if someone knows.. Thanks
Here is my code :
if (!_locationManager)
{
_locationManager = [[CLLocationManager alloc] init];
[_locationManager setDelegate:self];
}
[_locationManager startUpdatingLocation];
please help if someone knows.. Thanks
Add [locationManager requestAlwaysAuthorization]; to your code and add the entry NSLocationAlwaysUsageDescription to your .plist with the value being some sort of message that you want to ask the user for their permission.
You need to add a call to requestWhenInUseAuthorization when using location services for iOS-8.0 and above. Find the sample code below.
locationManager = [[CLLocationManager alloc]init];
locationManager.delegate = self;
// this check is required for iOS 8+
// selector 'requestWhenInUseAuthorization' is first introduced in iOS 8
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[locationManager requestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];
For more information see this blog.
Hope this helps.