Skip to content
Cordova iOS plugin exposing the WebRTC W3C API
Swift JavaScript Objective-C C
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
art Add art again. Jun 11, 2015
dist rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
docs rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
extra fix typo on extra/renderer-and-libwebrtc-tests.js Aug 15, 2019
js getUserMedia constraints: Allow `sourceId` (rather than just `deviceI… May 25, 2017
lib Update libWebRTC to revision 13311 Jul 11, 2016
src rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
.editorconfig Make indent width 4 Nov 21, 2016
.eslintrc
.gitignore - Rename Bridging-Header.h to cordova-plugin-iosrtc-Bridging-Header.h. May 28, 2015
.jshintrc jshint: Enable bitwise stuff. Nov 22, 2015
.travis.yml fix cordova-res was not found on travis bulild Aug 14, 2019
CHANGELOG.md rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
FAQ.md Add FAQ entry on removing multimedia controls from video elements Mar 26, 2017
ISSUE_TEMPLATE.md Improve ISSUE_TEMPLATE Jul 19, 2016
LICENSE rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
Makefile Add clean rule to Makefile Mar 25, 2017
README.md rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
WHO_USES_IT.md Repository transfer paper work Mar 27, 2017
banner.txt rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019
gulpfile.js migrate from jscs to eslint to fix '11 vulnerabilities (3 low, 1 mode… Aug 11, 2019
package-lock.json update package-lock.json using npm v6.4.1 Aug 15, 2019
package.json move xcode from devDependencies to dependencies as cordova 8+ install… Aug 14, 2019
plugin.xml rename repository from github.com/BasqueVoIPMafia to github.com/cordo… Aug 14, 2019

README.md

cordova-plugin-iosrtc

Cordova iOS plugin exposing the ̶f̶u̶l̶l̶ WebRTC W3C JavaScript APIs.

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 >= 7.2.1
  • iOS >= 9 (run on lower versions at your own risk, but don't report issues)
  • cordova-ios 4.X

Installation

Within your Cordova project:

$ cordova plugin add cordova-plugin-iosrtc

(or add it into a <plugin> entry in the config.xml of your app).

  • Remove the iOS platform and add it again (this apply "hook" file):
$ cordova platform remove ios
$ cordova platform add ios

Building

  • Building: Guidelines for building a Cordova iOS application including the cordova-plugin-iosrtc plugin.
  • Building libwebrtc: Guidelines for building Google's libwebrtc with modifications needed by the cordova-plugin-iosrtc plugin (just in case you want to use a different version of libwebrtc or apply your own changes to it).

Usage

The plugin exposes the cordova.plugins.iosrtc JavaScript namespace which contains all the WebRTC classes and functions.

var pc = new cordova.plugins.iosrtc.RTCPeerConnection({
  iceServers: []
});

cordova.plugins.iosrtc.getUserMedia(
  // constraints
  { audio: true, video: true },
  // success callback
  function (stream) {
    console.log('got local MediaStream: ', stream);

    pc.addStream(stream);
  },
  // failure callback
  function (error) {
    console.error('getUserMedia failed: ', error);
  }
);

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.addEventListener('deviceready', function () {
  // Just for iOS devices.
  if (window.device.platform === 'iOS') {
    cordova.plugins.iosrtc.registerGlobals();

    // load adapter.js
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "js/adapter-latest.js";
    script.async = false;
    document.getElementsByTagName("head")[0].appendChild(script);
  }
});

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.

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.

Changelog

See CHANGELOG.md.

Author

Iñaki Baz Castillo

Maintainers

Looking for new maintainers. Interested? Comment here.

License

MIT :)

You can’t perform that action at this time.