检测是否为我的应用启用位置服务 [英] Detecting whether location services are enabled for my app
问题描述
我知道设备会询问用户是否为该应用启用位置服务。
我正在开发我的第一个iOS应用,并使用用户的位置。 ,但是我怎么知道用户是否启用了它?
可能
'pre> [CLLocationManager authorizationStatus]!= kCLAuthorizationStatusDenied
应该是答案 developer.apple.com/library/mac/#documentation/CoreLocation/Reference/CL LocationManagerDelegate_Protocol / CLLocationManagerDelegate / CLLocationManagerDelegate.html#// apple_ref / OCC / INTF / CLLocationManagerDelegate相对= nofollow noreferrer> CLLocationManagerDelegate协议
相关SO问题是:
检查适用于iOS定位服务点击
的 locationServicesEnabled测试通过,当它们在viewDidLoad中被禁用时根据@albertamg的建议,如果您实现
你将被通知如果用户在请求时拒绝对位置服务的访问
请参阅 locationManager:didChangeAuthorizationStatus:
和 locationManager:didFailWithError:
方法
I'm developping my first iOS app, and this uses the user's location.
I know that the device asks the user whether to enable location services for the app, but how do I know if the user has enable it or not?
Probably
[CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied
should be the answer
releated SO questions are:
Checking for iOS Location Services
locationServicesEnabled test passes when they are disabled in viewDidLoad
and yes, according to @albertamg suggestion, if you implement CLLocationManagerDelegate protocol
you will be notified if user deny access to Location Services when you're requesting it
see locationManager:didChangeAuthorizationStatus:
and locationManager:didFailWithError:
methods
这篇关于检测是否为我的应用启用位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!