In the past, navigator.mediaDevices.getUserMedia()
was not available on WKWebView, but it has now been added as part of iOS 14.3, as these links show:
However, I updated the deployment target of an application to iOS 14.3 and then attached the Safari debugger to the WKWebView, but navigator.mediaDevices
still returns undefined when run on the JS console. In the third link above there are suggestions on steps to take in order to use getUserMedia
.
navigator.mediaDevices.getUserMedia
can now be exposed to WKWebView applications.navigator.mediaDevices.getUserMedia
is automatically exposed if the embedding application is able to natively capture either audio or video. Please refer to Apple documentation to meet these requirements.
I have followed the steps just in case but I still face the same problem.
Any ideas what I might be doing wrong? Has anyone else faced the same problem?
My guess is your content is not secure. If you navigate to a https:// location, navigator.mediaDevices will be available.
See 2nd note on this page: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia