Prevent for reprompting webRTC webView Permissions - ios15

Found an easy solution but should be integrated directly in @capacitor/ios and had no time to work on a pull request

I had to add these lines in the file node_modules/@capacitor/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift after the function public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!):

    @available(iOS 15, *)
    func webView(
        _ webView: WKWebView,
        requestMediaCapturePermissionFor origin: WKSecurityOrigin,
        initiatedByFrame frame: WKFrameInfo,
        type: WKMediaCaptureType,
        decisionHandler: @escaping (WKPermissionDecision) -> Void
    ) {
        decisionHandler(.grant)
    }

This delegates the permission request to your app and also remembers the user’s decision.

2 Likes