Enable WebRTC Support in WKWebView/UIWebView

4,247

ios Webview and WKWebView hasn't had WebRTC support until now.

From ios 14.3 ios is offering support for WKWebView: https://leemartin.medium.com/ios-14-3-brings-webrtc-to-wkwebview-closing-gap-on-ios-accessibility-90a83fa6bda2

You need to update your iOS in your phone and/or Xcode 12.3.

Additionally, depending on your webview plugin ( in my case I am using cordova-plugin-inappbrowser) could be necessary to modify it to add permissions for video, camera, and VoIP.

Share:
4,247
Faiizii Awan
Author by

Faiizii Awan

Sr Flutter Developer @ Infogistic Pvt. Ltd. (since Oct, 2020) with 2 Years of experience in Native Android Development having full expertise in Google APIs, Firebase, Dependency Injection (DI), Facebook SDK, Payments Systems, and Git Version Control Systems (VCSs).

Updated on December 07, 2022

Comments

  • Faiizii Awan
    Faiizii Awan over 1 year

    I am developing a flutter application using WebRTC in webview. On android, it is working as expected, but facing issues on iOS build. I have read the threads Apple Support and SO Thread.

    Both threads state, WebRTC is not allowed inside iOS webview. I tested my code in emulator/real-device, but unsuccessful.

    So, my question is anybody know how can I run the WebRTC in iOS webview?

    This is how I am showing the webview

    InAppWebView(
                    initialUrl: widget.callType == AppConstant.INCOMING ? incomingUrl : outGoingUrl,
                    initialOptions: InAppWebViewGroupOptions(
                      crossPlatform: InAppWebViewOptions(
                          mediaPlaybackRequiresUserGesture: false,
                          debuggingEnabled: true,
                          clearCache: true,
                          javaScriptEnabled: true,
                          preferredContentMode: UserPreferredContentMode.MOBILE
                      ),
                    ),
                    onWebViewCreated: (InAppWebViewController controller) {
                      //web view created
                    },
                    androidOnPermissionRequest: (InAppWebViewController controller, String origin, List<String> resources) async {
                      print('resource list : ${resources.toString()}');
                      return PermissionRequestResponse(resources: resources, action: PermissionRequestResponseAction.GRANT);
                    }
                );
    
  • Faiizii Awan
    Faiizii Awan over 3 years
    I am managing the device with iOS 14.3. I am using flutter development, so can not try Cordova plugin at first place. And please add a reference/example code of using cordova.
  • Faiizii Awan
    Faiizii Awan over 3 years
    iOS 14.3 has enabled the webrtc access. and it is working. future reader can check the functionality from listed samples webrtc.github.io/samples by running them in iOS safari browser.
  • umutcanturan
    umutcanturan about 3 years
    @FaiiziiAwan did you manage to run your app on iOS device(iOS 14.3 and/or above)?
  • oanfr
    oanfr over 2 years
    I was surprised to see that WebRTC works well on IOS using Chrome and Firefox as well as on IpadOS (Chrome/Firefox). Is that compatibility due to IOS 14.3 too ? Because I don't see any announcement yet as well as no WebRTC compatibility table update