RTCPeerConnection and RTCDataChannel shims for iOS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
WKWebViewWebRTCShim
bin
example
.gitignore ignore tons of annoying xcode things Jul 9, 2015
package.json
readme.md

readme.md

wkwebview-webrtc-shim

RTCPeerConnection and RTCDataChannel shim for iOS.

Why

So your WebRTC code can run on iOS.

How

Make a static library from this, then bind JavaScript to it across the postMessage bus.

Install

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

Example

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.

Test

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

License

MIT