25

我只是可以让我的 CLLocationManager 授权。(在 ios8 下 swift)我什至添加了一个明确的 requestAlwaysAuthorization 调用(我不需要在 ios7 下使用 objC)

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

回调永远不会得到任何东西,但 NotDermed 并且没有 UIAlertView 显示给用户。

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

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

4

4 回答 4

40

请记住NSLocationAlwaysUsageDescriptionorNSLocationWhenInUseUsageDescription键现在是强制性的,因此您应该将其包含在您的 plist 中。

于 2014-06-04T13:18:47.300 回答
3

您唯一需要做的就是将“NSLocationWhenInUseUsageDescription”键添加到您的应用程序 info.plist,然后创建一个 CLLocationManager requestWhenInUseAuthorization 方法并在 viewDidLoad 中调用它。

于 2014-06-06T09:46:57.980 回答
1

正如我的 objC 应用程序所发生的那样——我知道的那个在 ios7 下运行良好——我认为它应该是一个操作系统错误并报告了它:#17128352

于 2014-06-03T21:01:03.450 回答
-1

我有一个需要位置的键盘插件的有趣案例。

键盘位置使用权限始终被重置。您可以分别在两者中请求位置权限。但在iOS 设置应用程序中,它们都显示为一条记录,一般允许两条记录。

两者(应用程序嵌入式键盘)都有Info.plist文件。在两个文件中都指定NSLocationAlwaysUsageDescription/很重要。如果你错过了/在应用程序中,那么当你打开应用程序时,iOS 将重置获得的键盘权限!NSLocationWhenInUseUsageDescriptionInfo.plistNSLocationAlwaysUsageDescriptionNSLocationWhenInUseUsageDescriptionInfo.plist

于 2020-04-10T18:32:08.370 回答