检测是否为我的应用启用位置服务 [英] Detecting whether location services are enabled for my app

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

问题描述



我知道设备会询问用户是否为该应用启用位置服务。

我正在开发我的第一个iOS应用,并使用用户的位置。 ,但是我怎么知道用户是否启用了它?

解决方案

可能

'pre> [CLLocationManager authorizationStatus]!= kCLAuthorizationStatusDenied

应该是答案
相关SO问题是:

检查适用于iOS定位服务点击
locationServicesEnabled测试通过,当它们在viewDidLoad中被禁用时根据@albertamg的建议,如果您实现

developer.apple.com/library/mac/#documentation/CoreLocation/Reference/CL LocationManagerDelegate_Protocol / CLLocationManagerDelegate / CLLocationManagerDelegate.html#// apple_ref / OCC / INTF / CLLocationManagerDelegate相对= nofollow noreferrer> CLLocationManagerDelegate协议



你将被通知如果用户在请求时拒绝对位置服务的访问

请参阅 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屋!

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