Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLLocationManager.authorizationStatus() always CLAuthorizationStatus.NotDetermined with swift&objC app

Tags:

I just can get my CLLocationManager to authorise. (swift under ios8) I even add an explicit requestAlwaysAuthorization call (which I don't need with objC under ios7)

func finishLaunch() {     //ask for authorization     let status = CLLocationManager.authorizationStatus()     if(status == CLAuthorizationStatus.NotDetermined) {         self.locationManager.requestAlwaysAuthorization();     }     else {         self.startMonitoring()     }     ... } 

the callback never gets anything but NotDermined and there is no UIAlertView shown to the user.

func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {     if(status == CLAuthorizationStatus.NotDetermined) {         println("Auth status unkown still!");     }     self.startMonitoring() } 

Am I doing it wrong? -- Feels like a bug to me but I'd like some feedback

like image 517
Daij-Djan Avatar asked Jun 03 '14 20:06

Daij-Djan


2 Answers

Keep in mind that NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription keys are now mandatory, so you should include that in your plist.

like image 101
amb Avatar answered Sep 21 '22 22:09

amb


The only thing that you have to do is to add the Key "NSLocationWhenInUseUsageDescription" to your app info.plist then make a CLLocationManager requestWhenInUseAuthorization method and call it in the viewDidLoad.

like image 36
Tiago Sousa Avatar answered Sep 21 '22 22:09

Tiago Sousa