I'm using XCode 7.0 Beta and Swift.
I'm using MKMapView to display some places on a Map. Everything is ok : I see the Map and the place on the Map but I've the following error message :
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
In the Info.plist file, I've added NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription (see screenshot)
> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC
> "-//Apple//DTD PLIST 1.0//EN"
> "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist
> version="1.0"> <dict> <key>NSLocationAlwaysUsageDescription</key>
> <string>Test is NSLocationAlwaysUsageDescription</string>
> <key>NSLocationWhenInUseUsageDescription</key> <string>This is
> NSLocationWhenInUseUsageDescription</string>
In viewDidLoad, I've the following code
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController {
@IBOutlet weak var btn: UIButton!
@IBOutlet weak var Map: MKMapView!
@IBAction func btnClick(sender: AnyObject) {
}
override func viewDidLoad() {
super.viewDidLoad()
let locationManager = CLLocationManager()
var CLAuthStatus = CLLocationManager.authorizationStatus()
if(CLAuthStatus == CLAuthorizationStatus.NotDetermined) {
locationManager.requestAlwaysAuthorization();
}
When I run the code, in the simulator, I don't have any warning or any prompt to ask me the authorisation.
What's wrong ?
Thanks in advance
Have a nice day
Ghislain