Dismiss keyboard for PHPickerViewController not working

I'm using PHPickerViewController in my app and I want to keep it open even after the user selects an image. My flow is the following: after the user select the photo, another viewController is presented modally over it, displaying the selected photo. The user can dismiss this viewController and come back to the picker.

The issue is that in case the keyboard is open in the PHPickerViewController and I select an image, the keyboard is not dismissed no matter what I do. I tried the following:

func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
        guard let provider = results.first?.itemProvider else {
            return
        }

        if provider.canLoadObject(ofClass: UIImage.self) {
            provider.loadObject(ofClass: UIImage.self) { image, _ in
                guard let image = image as? UIImage else {
                    print("Error converting image")
                    return
                }
                DispatchQueue.main.async { [weak self] in
                    self?.dismissKeyboard() // -> HERE I TRY TO DISMISS THE KEYBOARD
                    self?.presentImagePreviewViewController(image: image)
                }
            }
        }
    }

func dismissKeyboard() {
        // NONE OF THESE DISMISS THE KEYBOARD
        phPickerViewController?.view.endEditing(true)
        phPickerViewController?.view.resignFirstResponder()
        view.endEditing(true)
        view.resignFirstResponder()
        UIApplication.shared.sendAction(
            #selector(UIApplication.resignFirstResponder), to: nil, from: nil, for: nil)
        UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
    }

I am assuming that this is because the picker runs on a separate process and doesn't get the dismiss keyboard notification. As per the documentation here.

Displaying the photo library doesn’t need user permission because it’s running in a separate process.

Can I dismiss the keyboard in any other way?