How can I check if my app has received location tracking permission? (Как я могу проверить, получило ли моё приложение разрешение на отслеживание местоположения?) - Swift 5
import CoreLocation
extension ViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
switch status {
case .notDetermined:
print("not determined - hence ask for Permission")
manager.requestWhenInUseAuthorization()
case .restricted, .denied:
print("permission denied")
case .authorizedAlways, .authorizedWhenInUse:
print("Apple delegate gives the call back here once user taps Allow option, Make sure delegate is set to self")
default:
break
}
}
}
Возврат к списку