From iOS 13 onwards, Apple replace "Always allow" to "Always once" from permission screen and moved "Always allow" in the settings.
If user select "Always once" then app will prompt location permission screen every time user launch the app.
If user select "While in use" then app will not prompt permission screen next time explicitly user need to travel to settings and give the permission.
Also receiving location update from switching to "While using app" to "Always Allow" from settings works for me.
Here is the properties I specifies
let locationManager = CLLocationManager()
locationManager.requestAlwaysAuthorization()
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
.
.
.
extension AppDelegate: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
switch status {
case .authorizedAlways, .authorizedWhenInUse:
locationManager.startUpdatingLocation()
case .denied:
print("Location permission denied")
case .restricted:
print("Location permission restricted")
case .notDetermined:
print("Location permission notDetermined")
@unknown default:
fatalError()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("Location Update = \(String(describing: locations.first))")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Location Error = \(error.localizedDescription)")
}
}