cordova-ios
cordova-ios copied to clipboard
[enhancement] add requestMediaCapturePermissionForOrigin support to avoid multiple permission request on getUserMedia call
Feature Request
Motivation Behind Feature
If use native WebRTC from WKWebView inside Cordova, every getUserMedia leads to new permission request to user. And this makes native WebRTC almost not suitable for use in production.
Feature Description
The simplest solution is add
- (void)webView:(WKWebView *)webView
requestMediaCapturePermissionForOrigin:(WKSecurityOrigin *)origin
initiatedByFrame:(WKFrameInfo *)frame
type:(WKMediaCaptureType)type
decisionHandler:(void (^)(WKPermissionDecision decision))decisionHandler
API_AVAILABLE(ios(15.0))
{
decisionHandler(WKPermissionDecisionGrant);
}
to https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewUIDelegate.m but it's definitely insecure solution, and application should have ability to respond to this request, or provide list of safe origins.
Alternatives or Workarounds
Didn't find any
Same issue here with microphone access permission in general (aka everything related to navigator.mediaDevices
).
Any news?
react-native-webview solution: https://github.com/react-native-webview/react-native-webview/pull/2257
Ionic WKWebView solution: https://github.com/ionic-team/capacitor/issues/5485 https://github.com/ionic-team/capacitor/blob/main/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift#L53
Home Assistant solution: https://github.com/home-assistant/iOS/issues/1671
I've tried the suggested solution and it's working pretty well. The app will still ask you once if you've never given the permission before, it will remember it afterwards and other instances of WKWebView with inAppBrowser for example will not automatically get the same permission!
I've tried the suggested solution and it's working pretty well. The app will still ask you once if you've never given the permission before, it will remember it afterwards and other instances of WKWebView with inAppBrowser for example will not automatically get the same permission!
This works really good! I It would be nice to have this implemented by default or as an option. For the moment, we wrote a hook for it to modify the file.