It is now a property of CLLocationManager
, authorizationStatus
. So, create a CLLocationManager
instance:
let manager = CLLocationManager()
Then you can access the property from there:
switch manager.authorizationStatus {
case .restricted, .denied:
...
default:
...
}
There are a few location related changes in iOS 14. See WWDC 2020 What’s new in location.
Needless to say, if you also need to support iOS versions prior to 14, then just add the #available
check, e.g.:
let authorizationStatus: CLAuthorizationStatus
if #available(iOS 14, *) {
authorizationStatus = manager.authorizationStatus
} else {
authorizationStatus = CLLocationManager.authorizationStatus()
}
switch authorizationStatus {
case .restricted, .denied:
...
default:
...
}