Brad
Brad

Reputation: 11515

How can I tell if an iOS device has a GPS?

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?

Upvotes: 12

Views: 13652

Answers (4)

AlexWien
AlexWien

Reputation: 28757

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;
}

Upvotes: 1

user2565077
user2565077

Reputation: 80

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.

Upvotes: 4

Lara
Lara

Reputation: 11

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

Upvotes: 0

fbrozovic
fbrozovic

Reputation: 490

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. :)

Upvotes: 11

Related Questions