Waffles Waffles - 6 months ago 17x
Swift Question

CLLocationManager not popping up a request for user to approve location tracking on iOS 9?

I have added to my Info.plist, set the Type to String and added "allow location?" as the Value.

I then added

import CoreLocation
to the tableviewcontroller, added
to the class types, declared a variable
var locationManager: CLLocationManager!
and in viewDidLoad() I typed:

locationManager = CLLocationManager()
locationManager.delegate = self

I feel like this is everything I need to do but it's not working at all, no pop up requests, nothing


Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.

There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my problem.

enter image description here Referred from link.