1

Is it possible to tell for certain whether or not a device has GPS hardware, without maintaining a list of devices that have GPS hardware (as described here)?

The answer to this question references using CLLocationManager, but provides a dead link.

I also read about checking whether or not the device has a carrier. I'm assuming this would require the device to actually have an active SIM card, which would cause problems with test devices and a few other edge cases.

Community
  • 1
  • 1
NMunro
  • 1,282
  • 4
  • 18
  • 33
  • A GPS is a passive device, similar to a portable FM Radio. It only receives signals, and doesn't transmit them, so checking for a sim card is a hit or miss. – DarthCaniac Feb 13 '14 at 21:55
  • 2
    You are not supposed to check the hardware. You are supposed to check the ability of the GPS to be _used_. If you don't want your app to run at all unless there is a GPS you can restrict it in the Info.plist (UIRequiredDeviceCapabilities). But otherwise your job is to fail gracefully if the device is not giving as accurate a fix as you would like (and be sure to allow plenty of time, as it can take quite a while for the GPS to "warm up"). – matt Feb 13 '14 at 21:56
  • @matt I want the app to run, I just want to block certain features which won't work without GPS, but want certain messaging if the user is just has GPS turned off, compared to when they can't turn it on (i.e using iPod touch). – NMunro Feb 13 '14 at 21:58
  • @NMunro How would the user have "GPS turned off"? There is no switch for that. The user can turn off Core Location as a whole, but you would have no difficulty whatever in detecting _that_. But as far as _using_ Core Location is concerned, the result you get is the result you get; Apple does not want you to think about _how_ that result was obtained. – matt Feb 13 '14 at 22:18
  • @matt Location services can be turned off for individual apps. – Nick Feb 13 '14 at 22:29
  • @Nick Yes, location services can be enabled per application, but the user only decides whether or not to let a given app access location data *at all* -- they don't allow/disallow access to the GPS specifically. Core Location uses several methods to determine location, and GPS is only one of those. Others include proximity to cell towers and proximity to known wifi hotspots. – Caleb Feb 13 '14 at 22:39
  • @matt Yes, I realise that - my comment was coming from the fact that I think when NMunro says turn GPS off he means turn location services off. – Nick Feb 13 '14 at 22:41
  • This question is not a duplicate, the question you guys are referencing is 3 years old and doesn't provide a solution to what I'm asking – NMunro Feb 14 '14 at 14:10

2 Answers2

1

There is no API to determine this directly. Also, a bluetooth GPS device can be connected and provide GPS capability to iOS devices with no intrinsic GPS capability. My own tests showed that the horizontal accuracy reported by CLLocationManager will never go below +/- 65m, if there is no GPS (or GPS satellite reception, e.g. indoors away from windows).

user3071962
  • 320
  • 3
  • 8
0

You could (and should) use the locationServicesEnabled: class method of CLLocationManager to determine whether or not the user has location services turned on for your application.

Nick
  • 939
  • 1
  • 12
  • 19
  • 1
    That has nothing to do with whether the device has GPS. Even without GPS, location services will attempt to work out the device location from things like Wifi locations. – Tom Harrington Feb 13 '14 at 22:56
  • I based my answer on the fact that I believe the question is related to whether location services is enabled, not GPS. – Nick Feb 14 '14 at 06:40
  • 1
    I'm not looking for whether or not they turned on GPS, I'm looking for whether or not the device they're using has GPS. – NMunro Feb 14 '14 at 14:08