locationServicesEnabled()
Returns a Boolean value indicating whether location services are enabled on the device.
Declaration
class func locationServicesEnabled() -> BoolReturn 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.
When users disable the switch, the system calls your delegate’s locationManager(_:didChangeAuthorization:) method with a denied authorization status (CLAuthorizationStatus.denied).
When users enable the switch, the system returns your app’s authorization to its previous state and calls your delegate’s locationManager(_:didChangeAuthorization:) method.
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.