Reputation: 24757
I want to check if the device has GPS or not.
Is there a way to do that?
Upvotes: 0
Views: 204
Reputation: 246
A problem exists when you are on a device with no cell and no gps. If wifi is turned off, locationServicesEnabled still returns YES even though there is no way for the device to get location updates. This is why we need to check for gps and/or cell -- assuming they always come as a pair. Unfortunately there is no good way to check for gps/cell.
Oddly, locationManager:didUpdateToLocation:fromLocation: still gets called in this situation, but locationManager.location is set to nil.
So the thing to do to see if locationServices is available is the following:
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized && locationManager.location) {
}
locationServicesEnabled checks if location services are on for the device, authorizationStatus checks if services are authorized for your app, and locationManager.location checks if location is updating.
Or so I think.
Upvotes: 0
Reputation: 12081
Using the CLLocationManager
you can see if location is enabled.
+ (BOOL) [CLLocationManager locationServicesEnabled];
However there's no way to see if this results in a location determined by cell towers, gps or wifi.
Upvotes: 2