Post

Replies

Boosts

Views

Activity

No prompt showing for WKWebView getUserMedia({audio: true})
A JavaScript library implementation (Twilio Voice JS) on MacOS requires media permissions, specifically microphone permissions. To do so in web browsers, one typical calls: navigator.mediaDevices.getUserMedia({audio: true}) .then((e) => alert("Permissions granted")) .catch((e) => alert("Permissions Denied")) The same could be done in a WKWebView either by evaluateJavaScript or by loading a script (or html file) from local resources. In these cases navigator.mediaDevices would only be made available if called from a "secure" site (i.e. https) or loaded locally e.g. via an html file from bundle resources. See secure note The issue is quite simple: Calling getUserMedia via Safari WKWebView inspector console hangs in terminal. It doesn't complete. It doesn't show a prompt. The promise doesn't resolve, reject or throw an error, nothing. Context Environment: Flutter MacOS plugin, XCode 14.2. Targeting macOS +11.0 with a Headless WKWebView. Info.plist includes Microphone permissions as required Hardened Runtime includes Audio Input, Sandbox includes bluetooth, Audio Input & outgoing connections. Manually prompting permissions documented here shows prompt. (System) Preferences > Security & Privacy > Microphone lists app with permissions. Safari (console) > Preferences > Websites > Microphone does not show any allowed permissions, with Ask required Media & supporting docs Current output Current output for enumeratedDevices and getUserMedia in WKWebView: Expected output Safari output, showing enumeratedDevices before and after requesting permissions: The issue is quite simple: calling getUserMedia via Safari WKWebView inspector console hangs in terminal. It doesn't complete. It doesn't show a prompt. The promise doesn't resolve, reject or throw an error, nothing. Question What is causing this hanging/what am I missing?
2
0
1.3k
Jul ’23