Detecting whether location services are enabled for my app

99封情书 提交于 2019-12-03 07:24:47

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/7221004/detecting-whether-location-services-are-enabled-for-my-app

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