Asking Location Permission is not working on the AppIntents

@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.

  1. It's really weird and unexpected that it throws UserLocationError.permissionDenied when the status is not .denied or .restricted
  2. Even it invokes requestWhenInUseAuthorization(), there's no alert for asking permission

If there's any solution, please let me know

Asking Location Permission is not working on the AppIntents
 
 
Q