CLLocationManager.authorizationStatus()始终使用swift&objC app确认CLAuthorizationStatus.NotDetermined

Dai*_*jan 21 cllocationmanager swift ios8

我只能让我的CLLocationManager进行授权.(在ios8下迅速)我甚至添加了一个显式的requestAlwaysAuthorization调用(在ios7下我不需要使用objC)

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

回调永远不会得到任何东西,但NotDermined并没有向用户显示UIAlertView.

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

我做错了吗? - 对我来说感觉像个臭虫,但我想要一些反馈

amb*_*amb 39

请记住,NSLocationAlwaysUsageDescription或者NSLocationWhenInUseUsageDescription密钥现在是强制性的,因此您应该将其包含在plist中.

  • 感谢您的支持.该错误仍然有效,因为我甚至无法通过设置应用程序进行授权,但这是我的解决方案 (2认同)