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

折月煮酒 提交于 2019-12-21 07:07:03

问题


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


回答1:


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




回答2:


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.




回答3:


As it happens with my objC app as well -- the one I KNOW works fine under ios7 -- I figured it should be a OS bug and reported it: #17128352



来源:https://stackoverflow.com/questions/24024116/cllocationmanager-authorizationstatus-always-clauthorizationstatus-notdetermin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!