didUpdateLocations not called

Furthermore in iOS8 you must have two extra things: Add a key to your Info.plist and request authorization from the location manager asking it to start. NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription You need to request authorization for the corresponding location method. [self.locationManager requestWhenInUseAuthorization] [self.locationManager requestAlwaysAuthorization] Code example: self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; // Check for … Read more

Battery drain when using CoreLocation Significant Location Monitoring & CoreBluetooth

At the end of the day, Apple’s suggestion of removing location from UIBackgroundModes fixed our battery drain issue. In order to still get locations in the background we had to wrap the [locationManager startLocationUpdates] & [locationManager stopLocationUpdates] calls with: [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler]; [[UIApplication sharedApplication] endBackgroundTask:];

CLLocationManager startUpdatingLocation not calling locationManager:didUpdateLocations: or locationManager:didFailWithError:

Just add this in info.plist NSLocationAlwaysUsageDescription — I need Location NSLocationWhenInUseUsageDescription — I need Location privacy – location usage description — I need Location Note that “I need Location” should be changed to describe your actual app’s designed usage. It is communicated to the end user in the authorization message. (thanks @devios1) locationManager = [[CLLocationManager … Read more

iOS – MKMapView place annotation by using address instead of lat / long

Based on psoft‘s excellent information, I was able to achieve what I was looking for with this code. NSString *location = @”some address, state, and zip”; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location completionHandler:^(NSArray* placemarks, NSError* error){ if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] … Read more

Checking location service permission on iOS

This is the correct. if ([CLLocationManager locationServicesEnabled]){ NSLog(@”Location Services Enabled”); if ([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){ alert = [[UIAlertView alloc] initWithTitle:@”App Permission Denied” message:@”To re-enable, please go to Settings and turn on Location Service for this app.” delegate:nil cancelButtonTitle:@”OK” otherButtonTitles:nil]; [alert show]; } }

Replacement for “purpose” property of CLLocationManager

The replacement for the purpose property in iOS 6 is a new Info.plist key named NSLocationUsageDescription (aka “Privacy – Location Usage Description”). The key is documented in the Information Property List Key Reference but unfortunately it’s not mentioned with the deprecation note of the purpose property. However, the CLLocationManager.h does have this comment: * Deprecated. … Read more

How to get current longitude and latitude using CLLocationManager-Swift

IMHO, you are over complicating your code when the solution you are looking is pretty simple. I have done it by using the following code: First create an instance of CLLocationManager and Request Authorization var locManager = CLLocationManager() locManager.requestWhenInUseAuthorization() then check if the user allowed authorization. var currentLocation: CLLocation! if CLLocationManager.authorizationStatus() == .authorizedWhenInUse || CLLocationManager.authorizationStatus() … Read more

iOS 8 Map Kit Obj-C Cannot Get Users Location

I got it working. I’ve posted my code below to help anyone else having issues. Here is my full code to get the MapKit Map View working in iOS 8. In your AppName-Info.plist Add a new row with the key name being: NSLocationWhenInUseUsageDescription Or NSLocationAlwaysUsageDescription With the value being a string of the message that … Read more

Show Current Location and Update Location in MKMapView in Swift

You have to override CLLocationManager.didUpdateLocations (part of CLLocationManagerDelegate) to get notified when the location manager retrieves the current location: func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let location = locations.last{ let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) self.map.setRegion(region, animated: true) } } NOTE: … Read more