iOS 10.3 WKWebView crash when accessing Photo Library

932 Views Asked by At

On iOS 10.3 simulator when I try to upload an image from the Photo Library through WKWebView my app crashes with error: "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera'".

On a iOS 10.3.2 device it no longer gives me the option to upload from PhotoLibrary. It just goes straight to the camera.

It works fine on previous iOS versions and I have all the required permissions. My guess is that the issue is coming internally from WKWebView.

Does anybody know how to fix this or modify the upload functionality?

1

There are 1 best solutions below

1
On

I actually figured it out. Turns out that WKWebView on iOS 10.3 started respecting the HTML Media Capture attribute on file inputs. This is why on the actual device it would no longer give the "Photo Library" options and would always go straight to the Camera. The simulator does seem to be buggy since it does not support a Camera but it still displays a "Photo Library" option, and when you click on the "Photo Library" it crashes the app.