cordova-plugin-iosrtc-capacitor
Cordova iOS plugin exposing the ̶f̶u̶l̶l̶ WebRTC W3C JavaScript APIs.
- Public Google Group (mailing list) for questions and discussions about cordova-plugin-iosrtc-capacitor.
- Bug Tracker for reporting issues and requesting new features (please don't use the bug tracker for questions or problems, use the mailing list instead).
- NPM package.
Yet another WebRTC SDK for iOS?
Absolutely not. This plugin exposes the WebRTC W3C API for Cordova iOS apps (you know there is no WebRTC in iOS, right?), which means no need to learn "yet another WebRTC API" and no need to use a specific service/product/provider.
Who?
This plugin was initially developed at eFace2Face, and later maintained by the community, specially by Saúl Ibarra Corretgé (The OpenSource Warrior Who Does Not Burn).
Requirements
In order to make this Cordova plugin run into a iOS application some requirements must be satisfied in both development computer and target devices:
- Xcode >= 11.1 (11A1027)
- iOS >= 10.2 (run on lower versions at your own risk, don't report issues)
swift-version
=> 4.2cordova
>= 7.1.0cordova-ios
>= 4.5.1
Third-Party Supported Library
- WebRTC W3C v1.0.0
- WebRTC.framework => M69
- Janus => 0.7.4
- JSSip => 3.1.2
- Sip.js => 0.15.6
- OpenEasyrtc => 2.0.3
- openvidu => 2.11.0
- Ionic => v8
- Jitsi ~ 3229
Installation
Within your Cordova project:
$ cordova plugin add cordova-plugin-iosrtc-capacitor
(or add it into a <plugin>
entry in the config.xml
of your app).
Building
- Last Tested WebRTC.framework version: M69 on cordova-plugin-iosrtc-capacitor version 6.0.0
- Building: Guidelines for building a Cordova iOS application including the cordova-plugin-iosrtc-capacitor plugin.
- Building
libwebrtc
: Guidelines for building Google's libwebrtc with modifications needed by the cordova-plugin-iosrtc-capacitor plugin (just in case you want to use a different version of libwebrtc or apply your own changes to it).
Sample Application
The cordova-plugin-iosrtc-capacitor-sample
include mutiple example for using cordova-plugin-iosrtc-capacitor
with JsSip, Janus, EasyRTC, and basic WebSocket Signaling. It's is used to test cordova-plugin-iosrtc-capacitor
new release and reproduce reported issues.
Usage
The plugin exposes the cordova.plugins.iosrtc
JavaScript namespace which contains all the WebRTC classes and functions.
/* global RTCPeerConnection */ //// Container for this sample// var appContainer = documentbody;appContainerinnerHTML = ""; //// Sample getUserMedia// // var localStream localVideoEl; { localVideoEl = document; localVideoElstyleheight = "50vh"; localVideoEl; localVideoEl; appContainer; return navigatormediaDevices;} //// Sample RTCPeerConnection// var pc1 pc2; var peerConnectionConfig = offerToReceiveVideo: true offerToReceiveAudio: true //iceTransportPolicy: 'relay', sdpSemantics: 'unified-plan' //sdpSemantics: 'plan-b', bundlePolicy: 'max-compat' rtcpMuxPolicy: 'negotiate' iceServers: url: "stun:stun.stunprotocol.org" ; var peerVideoEl peerStream; { pc1 = peerConnectionConfig; pc2 = peerConnectionConfig; // Note: Deprecated but supported //pc1.addStream(localStream); // Add local stream tracks to RTCPeerConnection var localPeerStream = ; localStream; // Basic RTCPeerConnection Local WebRTC Signaling follow. { console; return can && pc; } pc1; pc2; { // Create peer video element peerVideoEl = document; peerVideoElstyleheight = "50vh"; peerVideoEl; peerVideoEl; appContainer; // Note: Expose for debug peerStream = stream; // Attach peer stream to video element peerVideoElsrcObject = peerStream; } // This plugin handle 'addstream' and 'track' event for MediaStream creation. var useTrackEvent = Objectontrack; // Using 'track' event with existing MediaStream if useTrackEvent ; pc2; // Using addstream to get MediaStream else pc2; pc1; pc1; pc1;} { // Note: This allow this sample to run on any Browser var cordova = windowcordova; if cordova && cordovaplugins && cordovapluginsiosrtc // Expose WebRTC and GetUserMedia SHIM as Globals (Optional) // Alternatively WebRTC API will be inside cordova.plugins.iosrtc namespace cordovapluginsiosrtc; // Enable iosrtc debug (Optional) cordovapluginsiosrtcdebug; // Run sample ;} if documentreadyState === "complete" || documentreadyState === "loaded" ; else window; // See ./extra/renderer-and-libwebrtc-tests.js for more samples usage.
In case you'd like to expose the API in the global namespace like regular browsers you can do the following:
// Just for Cordova apps.document;
And that's all. Now you have window.RTCPeerConnection
, navigator.getUserMedia
, etc.
FAQ
See the FAQ.
Documentation
Read the full documentation in the docs folder.
Who Uses It
People and companies using cordova-plugin-iosrtc-capacitor.
If you are using the plugin we would love to hear back from you!
Known Issues
iOS Safari and crash on WebSocket events
Don't call plugin methods within WebSocket events (onopen
, onmessage
, etc). There is an issue in iOS Safari (see issue #12). Instead run a setTimeout()
within the WebSocket event if you need to call plugin methods on it.
Or better yet, include the provided ios-websocket-hack.js in your app and load into your index.html
as follows:
<script src="cordova.js"></script>
<script src="ios-websocket-hack.min.js"></script>
HTML5 video API
There is no real media source attached to the <video>
element so some HTML5 video events and properties are artificially emitted/set by the plugin on behalf of the video element.
Methods such as play()
, pause()
are not implemented. In order to pause a video just set enabled = false
on the associated MediaStreamTrack
.
iOS >= 13.3.1 Device support
To run on Devices with iOS >= 13.3.1, you need a valid Apple Developer account to sign the WebRTC dynamic frameworks for more info see https://stackoverflow.com/a/60090629/8691951
Changelog
See CHANGELOG.md.
Author
Maintainers
- Harold Thetiot
- Iñaki Baz Castillo (no longer active maintainer)
- Saúl Ibarra Corretgé (no longer active maintainer)
Looking for new maintainers. Interested? Comment here.
License
MIT :)