Vin
Vin

Reputation: 98

How to handle file upload in WKWebView?

I am displaying a html page using WKWebView in Swift 5. I have an option to upload image using input file tag. When I run the app and click on upload, it prompts to select Photo library or Camera. If I select camera, the app crashes since the app doesn't have permission.

How to remove camera option or properly request the permission when the user selects camera?

Upvotes: 2

Views: 3883

Answers (2)

stackich
stackich

Reputation: 5287

Regarding your first question - "How to remove camera option":

As far as I know it is not possible. You can either show a dialog which asks for image source (library, camera or Files) or you can select camera only using capture:

<input type="file" accept="image/*" capture>

Something like capture, but for Photo Library is not supported.

Check filter options here.

Upvotes: 0

Mitesh
Mitesh

Reputation: 534

I am not sure but you can just set key Privacy - Camera Usage Description in info.plist file with description. Web view will manage for permission and it will work. Please check and let me know if work for you.

Upvotes: 3

Related Questions