@MainActor
perform() async throws -> some IntentResult {
// ...
switch locationManager.authorizationStatus {
case .denied, .restricted:
throw UserLocationError.permissionDenied
case .notDetermined:
await locationManager.requestWhenInUseAuthorization() // to ask permission
default:
break
}
// ...
}
Here is my code.
When the authorizationStatus
is .notDetermined
,
it invokes requestWhenInUseAuthorization()
method on the main thread,
but throws UserLocationError.permissionDenied
immediately, eventhough I didn't deny the permission.
- It's really weird and unexpected that it throws
UserLocationError.permissionDenied
when the status is not.denied
or.restricted
- Even it invokes
requestWhenInUseAuthorization()
, there's no alert for asking permission
If there's any solution, please let me know