Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS check on app if GPS is off

Tags:

ios

gps

mkmapview

Hi I have an app that gives you locations on the mapview, is there any method to implement on an IF.

I would like my app to check if you don't have the gps active instead of showing you the map it will show you an image saying you don't have connection.

I would like to do something similar if you don't have signal as well.

like image 248
dastjuso Avatar asked Jun 23 '13 18:06

dastjuso


People also ask

Can my phone be tracked if Location Services is off?

The answer is yes, it's possible to track mobile phones even if location services are turned off.

How do I know if location is off on iPhone?

Go to Settings > Privacy, then select Location Services. Select an app, then turn Precise Location on or off.


1 Answers

You can check whether the user denied the location services for you application by

[CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied

Otherwise you can also check whether location services are available at a system level by

[CLLocationManager locationServicesEnabled]

So the check you may want to perform in your app looks like

if([CLLocationManager locationServicesEnabled] && 
   [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) {
    // show the map
} else {
    // show error
}
like image 179
Gabriele Petronella Avatar answered Oct 28 '22 02:10

Gabriele Petronella