Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] add requestMediaCapturePermissionForOrigin support to avoid multiple permission request on getUserMedia call #1166

Open
RSATom opened this issue Oct 28, 2021 · 3 comments · May be fixed by #1245

Comments

@RSATom
Copy link

RSATom commented Oct 28, 2021

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

@RSATom RSATom changed the title add requestMediaCapturePermissionForOrigin support to avoid multiple permission request on getUserMedia call [enhancement] add requestMediaCapturePermissionForOrigin support to avoid multiple permission request on getUserMedia call Oct 28, 2021
@fq-selbach
Copy link

fq-selbach commented Mar 30, 2022

Same issue here with microphone access permission in general (aka everything related to navigator.mediaDevices).

Any news?

react-native-webview solution:
react-native-webview/react-native-webview#2257

Ionic WKWebView solution:
ionic-team/capacitor#5485
https://github.com/ionic-team/capacitor/blob/main/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift#L53

Home Assistant solution:
home-assistant/iOS#1671

@fquirin
Copy link

fquirin commented Mar 31, 2022

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!

@derMani
Copy link

derMani commented Apr 26, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants