RTCPeerConnection
and RTCDataChannel
shim for iOS.
So your WebRTC code can run on iOS.
Make a static library from this, then bind JavaScript to it across the postMessage bus.
First download and build libWebRTC (be warned, it takes a while):
$ bin/build-libwebrtc
Then drag the folder called "WKWebViewWebRTCShim" into your xcode project and import these frameworks:
- libc++.dylib
- libz.1.2.5.dylib
- AVFoundation.framework
- AudioToolbox.framework
- CoreMedia.framework
This code shows how to create and shim a WKWebView in Swift:
var configuration = WKWebViewConfiguration()
var controller = WKUserContentController()
configuration.userContentController = controller
var webView = WKWebView(frame: container.frame, configuration: configuration)
container.addSubview(webView)
// apply shim
WKWebViewWebRTCShim(webView: webView, contentController: controller)
var request = NSURLRequest(URL: NSURL(string:"http://instant.io")!)
webView.loadRequest(request)
Note: since the shim is written in Objective C, you will need a bridging header to use it with swift.
Install some dev dependencies:
$ npm install
Serve up simple-peer's tests with zuul:
$ npm run test
Open the example app in xcode and run it:
$ open example/WKWebViewWebRTCShimExample.xcodeproj
MIT