如何在iOS 4.2之前检查是否为特定应用启用了位置服务? [英] How to check if location services are enabled for a particular app prior to iOS 4.2?

查看:108
本文介绍了如何在iOS 4.2之前检查是否为特定应用启用了位置服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查用户是否允许mu app的位置?
通常我会使用 CLLocationManager 类的 authorizationStatus 方法,但它仅适用于iOS 4.2和新。是否有可能在使用SDK 4.2时以某种方式实现这一点,以便应用程序仍然可以在具有旧版iOS的设备上运行,或者我是否必须降级SDK?
沿着同一行,我需要为iOS 4.0之前的 locationServicesEnabled 方法提供类似的替代方案。

How can I check if the user has allowed location for mu app? Normally I would use authorizationStatus method of the CLLocationManager class, but it is only available in iOS 4.2 and newer. Is it possible to achieve this somehow while still using SDK 4.2, so that the app can still run on devices with older versions of iOS, or do I have to downgrade the SDK? And along the same line, I need a similar alternative for the locationServicesEnabled method prior to iOS 4.0.

推荐答案

当您致电 -startUpdatingLocation 时,如果用户拒绝了位置服务,则位置管理员代表将接到对 -locationManager:didFailWithError:,带有 kCLErrorDenied 错误代码。这适用于所有版本的iOS。

When you call -startUpdatingLocation, if location services were denied by the user, the location manager delegate will receive a call to -locationManager:didFailWithError: with the kCLErrorDenied error code. This works both in all versions of iOS.

这篇关于如何在iOS 4.2之前检查是否为特定应用启用了位置服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆