开发者

Detecting whether location services are enabled for my app

开发者 https://www.devze.com 2023-04-01 10:39 出处:网络
I\'m developping my first iOS app, a开发者_运维知识库nd 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

I'm developping my first iOS app, a开发者_运维知识库nd 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号