Type Method

locationServicesEnabled()

Returns a Boolean value indicating whether location services are enabled on the device.

Declaration

class func locationServicesEnabled() -> Bool

Return Value

true if location services are enabled on the device; false if they are not.

Discussion

Users can enable or disable location services by toggling the Location Services switch in Settings > Privacy.

You are not required to call locationServicesEnabled(). However, If you wish to display instructions about enabling location services, you may check the return value of this method to find out if the services are disabled for the entire device, or just for your app. If the result is true, provide instructions for enabling services for your app; otherwise, provide instructions for enabling the Location Services switch in Settings > Privacy.

If users disable or deny location services and you attempt to start location updates anyway, the location manager reports an error to its delegate. See locationManager(_:didFailWithError:) and locationManager(_:monitoringDidFailFor:withError:) for more information.

See Also

Determining the Availability of Services

class func significantLocationChangeMonitoringAvailable() -> Bool

Returns a Boolean value indicating whether the significant-change location service is available on the device.

class func headingAvailable() -> Bool

Returns a Boolean value indicating whether the location manager is able to generate heading-related events.

class func isMonitoringAvailable(for: AnyClass) -> Bool

Returns a Boolean value indicating whether the device supports region monitoring using the specified class.

class func isRangingAvailable() -> Bool

Returns a Boolean value indicating whether the device supports ranging of beacons that use the iBeacon protocol.