11

I have created a chat but with webView. The problem is the chat has video and voice that is not supported with iOS because it does not support webRTC.

The main question is how can I easily add RTC inside webView in Swift to support iOS video and voice?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Steven
  • 762
  • 1
  • 10
  • 27
  • SFSafariViewController now supports webrtc in ios13. https://bugs.webkit.org/show_bug.cgi?id=183201#c28 – XDev 2381 Jun 17 '20 at 10:44
  • should probably update the accepted question to the 2nd answer, which is more updated. – zaxy78 Apr 14 '21 at 10:27
  • Does this answer your question? [WebApp using webRTC for cross-platform videochat in iOS Browser and Android Chrome](https://stackoverflow.com/questions/23374806/webapp-using-webrtc-for-cross-platform-videochat-in-ios-browser-and-android-chro) – outis Nov 04 '21 at 22:58

4 Answers4

5

From iOS 14.3 (Beta)

Apple is adding full support to WebRTC in WKWebView !

Learn more here: https://webkit.org/blog/11353/mediarecorder-api/

From iOS11+

Apple has added support for WebRTC to Safari.
If you want to use WKWebView - there is only a partial support. Checkout this answer:

WebRTC Support in iOS 11 - Explained

zaxy78
  • 1,406
  • 3
  • 19
  • 32
  • 1
    WKWebView still doesn't support WebRTC even Safari does – Luis Oct 13 '18 at 04:10
  • 1
    It does support *some* of its features, but not getUserMedia(). checkout my full answer here: https://stackoverflow.com/a/49467964/1047547 – zaxy78 Oct 14 '18 at 11:31
2

Unfortunately with the current WebRTC support in the iOS web browser, you can't easily add WebRTC. You would have to use the native iOS libraries (https://webrtc.org/native-code/ios/).

Chuck Hays
  • 1,194
  • 1
  • 6
  • 7
  • I think this has changed. iOS 11 has WebRTC support in it's WKWebView :) – zaxy78 Nov 02 '17 at 11:04
  • 1
    it's not WKWebView still doesn't support WebRTC – Luis Oct 13 '18 at 04:11
  • It has *some* supoort. checkout my answer here: https://stackoverflow.com/a/49467964/1047547 – zaxy78 Oct 14 '18 at 11:32
  • 1
    @zaxy78 any news with iOS 12 ? for getUserMedia – Luis Oct 21 '18 at 18:38
  • @Luis, I noticed someone found a WebKit JS call to re-activate the getUserMedia. want to try to reproduce and let us know if it really works? See the comment on this page: http://www.openradar.me/33571214 – zaxy78 Oct 22 '18 at 22:49
  • 1
    @zaxy78 it doesn't work the comment says "However, the call getUserMedia fails with the error "SecurityError: The operation is insecure.". I did not manage yet to work around it.", there is an internal ticket open on apple with id 29281220 , to resolve this issue ( there is no way to see the link to the ticket ) – Luis Oct 24 '18 at 02:40
  • disappointing :( but thanks for the update. will update if I notice a change – zaxy78 Oct 24 '18 at 09:07
  • 3
    will something change for iOS 13 ? – Mathias Aug 18 '19 at 13:31
  • Now, WKWebView on iOS 14.3 supports WebRTC – Almas Adilbek Jan 13 '21 at 07:02
  • @AlmasAdilbek yap, notice my answer below. – zaxy78 May 12 '21 at 07:19
2

getUserMedia not supported in WKWebView

This bug was filed in radar, which is Apple's bug tracking system : http://www.openradar.me/33571214

Ahmed Mihoub
  • 547
  • 4
  • 6
1

UPDATE: Unfortunately, there is only microphone support in this framework!


Finally, there is a solution!

WKWebViewRTC is a brand new WebRTC library for WKWebView for Swift on iOS, and it works like a charm!

https://github.com/OpenTelecom/WKWebViewRTC

  1. clone repository and build framework

  2. add framework to your project with "Embed & Sign" setting

  3. add this line of code after WKWebView initialization

     WKWebViewRTC(wkwebview: webView, contentController: controller)
    

This way mediaDevices and getUsermedia are available to use.

Minimum iOS version of framework is iOS 12.