12

For an iPad, or iPod touch, is there a way to find out if the device has GPS?

Extra Credit: What if the iPad itself does not, but it is connected to a third-party GPS unit? Can I determine this?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Brad
  • 11,262
  • 8
  • 55
  • 74

4 Answers4

11

Apple does not provide a function to directly query the device if it has GPS capabilities or not. There are two possible solutions to your problem:

  1. Query the device type and determine if it has GPS based on that. This is described here.

  2. The way Apple recommends: have a look at their documentation here (Section "Determining the available Hardware Support"). Basically you create an instance of CLLocationManager and set the desired accuracy to the highest level, after that you can query its accuracy; if it's not very accurate, it's likely that the device does not have GPS.

Hope this helps. :)

Community
  • 1
  • 1
fbrozovic
  • 490
  • 2
  • 11
  • Not really the answer I "wanted" - but it is correct, nonetheless ;-) – Brad Aug 24 '11 at 17:30
  • Revised advice on detecting Location Services is now here: https://developer.apple.com/documentation/corelocation/adding_location_services_to_your_app – JonH Dec 19 '21 at 17:13
4

For iOS 6 or higher, you might want to try

+ (BOOL)[CLLocationManager deferredLocationUpdatesAvailable]

According to the documentation:

Deferred location updates require the presence of GPS hardware and may not be supported on all iOS devices.

user2565077
  • 80
  • 1
  • 2
1

Only GPS can deliver the location attributes: course and speed.
And as a general rule, you need GPS for precise location, a device whitout GPS will deliver a location.getHoricontalAccuracy() higher than 30- 40m. (Using accuracy setting of CLLLocationAccuracyBest)

So In that case you dont have an accurate position and can ignore that always. (Independnet if the device has GPS or not)

// Check if the device has GPS hardware available
public bool CheckGpsHardware()
{
    var value = false;

    CLLocationManager locationManager = new CLLocationManager();
    locationManager.DesiredAccuracy = CLLocation.AccuracyBest;

    if (CLLocationManager.LocationServicesEnabled)
    {
        locationManager.RequestLocation();
        if (locationManager.Location?.HorizontalAccuracy < 0)
        {
            // GPS hardware is not available
            value = false;
        }
        else
        {
            // GPS hardware is available
            value = true;
        }
    }
    else
    {
        // Location services are not available
        value = false;
    }

    return value;
}
Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50
AlexWien
  • 28,470
  • 6
  • 53
  • 83
0

Download altimeter or similar app. Turn off cell data and wifi before you ever use the downloaded app. Then launch the app and see if it will give you Your current altitude. If it works you have GPS if it doesn't then you don't

Lara
  • 11
  • 2
    I would have downvoted the answer (as commented above) - however, the idea of looking at the returned "altitude" field was a decent idea. – Brad Nov 30 '12 at 15:54