getUserMedia not supported in WKWebView

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
One of the big announcements for the web in iOS 11 is support for getUserMedia in Safari (see 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

iOS 11 beta 4



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:


void WKPreferencesSetMediaDevicesEnabled(WKPreferences* preferencesRef, bool enabled);


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

I did put it in that function:

By stephane.magnenat at March 4, 2019, 3:37 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!