Returns a Boolean value indicating whether location services are enabled on the device.
- iOS 4.0+
- macOS 10.7+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
- Core Location
true if location services are enabled;
false if they are not.
The user can enable or disable location services from the Settings app by toggling the Location Services switch in General.
You should check the return value of this method before starting location updates to determine whether the user has location services enabled for the current device. Location services prompts users the first time they attempt to use location-related information in an app but does not prompt for subsequent attempts. If the user denies the use of location services and you attempt to start location updates anyway, the location manager reports an error to its delegate.