Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting whether location services are enabled for my app

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?

like image 773
Quentin DOMMERC Avatar asked Aug 28 '11 12:08

Quentin DOMMERC


People also ask

How do I know if my location is turned on IOS?

The user can enable or disable location services from the Settings app by toggling the Location Services switch in General. You should check the return value of locationServiceEnabled() method before starting location updates to determine whether the user has location services enabled for the current device.

Should Location Services be on or off?

Turn off GPS There are ways your device could still be tracked even after turning off location services but not turning it off is worse. Turning off location services on your phone provides a layer of security against the most common location trackers.


1 Answers

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

like image 135
Marek Sebera Avatar answered Oct 06 '22 08:10

Marek Sebera