getUserMedia not supported in WKWebView

Originator:darryl
Number:rdar://33571214 Date Originated:27-Jul-2017 10:56
Status:Duplicate/29281220 Resolved:
Product:iOS + SDK Product Version:iOS 11 beta 4
Classification:Other Bug Reproducible:Always
 
Summary:
One of the big announcements for the web in iOS 11 is support for getUserMedia in Safari (see https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Safari_11_0/Safari_11_0.html#//apple_ref/doc/uid/TP40014305-CH13-SW8 for announcement).  Sadly, it appears that getUserMedia is not enabled for applications that use a WKWebView.

Steps to Reproduce:
Call `getUserMedia` in a page loaded into a WKWebView

Expected Results:
Access to the microphone and camera

Actual Results:
The API is not available

Version:
iOS 11 beta 4

Notes:

Comments

We have same issue, and standard reply from Apple stuff - Duplicate of 29281220. We need this functionality for our app. Does anybody know when this issue will be fixed?

By andrew.akhiezer at Jan. 15, 2019, 9:28 a.m. (reply...)

I managed to re-enable the API, in the context of cordova-plugin-wkwebview-engine, by using the private WebKit function: void WKPreferencesSetMediaDevicesEnabled(WKPreferences* preferencesRef, bool enabled)

Assuming you are using Objective C, to reproduce, you need 1. to declare this function, and 2 when you are setting up WKWebViewConfiguration, call it:

1.

void WKPreferencesSetMediaDevicesEnabled(WKPreferences* preferencesRef, bool enabled);

2.

WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init]; ... WKPreferencesSetMediaDevicesEnabled(configuration.preferences, true);

However, the call getUserMedia fails with the error "SecurityError: The operation is insecure.". I did not manage yet to work around it.

By stephane.magnenat at Sept. 19, 2018, 1:35 p.m. (reply...)

Hi, Can you be more specific? Where should i declare the function WKPreferencesSetMediaDevicesEnabled(configuration.preferences, true); Thx


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!