MenuMenu

Write iOS apps using RTCMultiConnection

This documentation explains how to generate iphone/ipad apps

RTCMultiConnection v3 supports cordova/ionic/phonegap (webviews).

For more information: docs/ios-android.md

Want to build Android apps? Check this: Write Android apps

Development Environment Prerequisites

nameversion
MacOSX 10.11 or higher
xCode 7.3 or higher
iOS 9.2 or higher

Check if your system is ready (see how to install cordova)

cordova requirements

Above command will/should display a result similar to this:

Apple OS X: installed darwin ---- OSX should be 10.11 or higher
Xcode: installed 7.3         ---- 7.3 or higher
ios-deploy: installed 1.8.4  ---- optional
ios-sim: installed 5.0.6     ---- optional

Please make sure to re-install the prerequisites if you get different result.

Create Your First Cordova App

cordova create RTCMultiConnection com.rtcmulticonnection.demo RTCMultiConnection
cd RTCMultiConnection

Now you need to change following files:

namepathdescriptiondemo file
index.html www/index.html iOS app shows this HTML demo file
index.js www/js/index.js this is the backbone; here you do everything! demo file
config.xml config.xml here you set plugins, platforms, and attributes demo file

Modify index.html

<link type="text/css" href="css/index.css">
<script src="cordova.js"></script>
<script src="js/socket.io.js"></script>
<script src="js/RTCMultiConnection.js"></script>
<script src="js/index.js"></script>

Modify index.js

var app = {
    initialize: function() {
        app.bindEvents();
    },
    bindEvents: function() {
        document.addEventListener('deviceready', app.onDeviceReady, false);
    },
    onDeviceReady: function() {
        // here goes your real RTCMultiConnection codes
        var connection = new RTCMultiConnection();
        connection.socketURL = 'https://yourWebSite.com:9001/';
        connection.openOrJoin('roomid');
    }
};

app.initialize();

Modify config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.rtcmulticonnection.demo" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>RTCMultiConnection</name>
    <icon src="www/img/icon.png" />
    <content src="index.html" />
    <platform name="ios">
        <preference name="Orientation" value="all" />
        <hook src="hooks/iosrtc-swift-support.js" type="after_platform_add" />
        <config-file parent="CFBundleURLTypes" target="*-Info.plist">
            <array>
                <key>NSAppTransportSecurity</key>
                <dict>
                    <key>NSAllowsArbitraryLoads</key>
                    <true />
                </dict>
            </array>
        </config-file>
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="latest" />
    <plugin name="cordova-plugin-iosrtc" spec="latest" />
    <plugin name="cordova-plugin-device" spec="latest" />
</widget>

Please modify following XML attributes:

descriptionexample code
"id" attribute: It should be something like this:
<widget id="com.yourdomain"
"name" attribute: Name should NOT have spaces or special characters. Consider it as a "username":
<nameyourAppName</name
"icon" attribute: You can replace "icon.png" file with your own app-icon.

Download "iosrtc-swift-support.js" in the "hooks" directory

mkdir hooks
cd hooks
# wget http://webrtcweb.com/cordova-apps/video-conferencing/hooks/iosrtc-swift-support.js
wget https://raw.githubusercontent.com/eface2face/cordova-plugin-iosrtc/master/extra/hooks/iosrtc-swift-support.js

[sudo] chmod +x iosrtc-swift-support.js

Add iOS platform

cordova platform add ios

Open "xcodeproj" using xCode

platforms/ios/ProjectName.xcodeproj

You need to validate your iOS profile/email.

Add Two New Entires in the "Info.plist"

Using xCode, goto "info.plist" section and you MUST add following two entries:

Add "Privacy - Microphone" entry
Add "Privacy - Camera" entry

Build iOS

cordova build ios

Now click "Run" button on xCode to compile the iOS app and install on your real iPhone/iPad device. Please do NOT use emulators.

Test on a Real iPhone device

(Use USB cable) Plugin your iPhone (6p or 7) device to your MacBook

Open XCode and click "Generic iOS Device" from the tool-bar

Select your real iPhone device

Click "Run" button from the same tool-bar

It will generate iOS app, automatically install it on your real iPhone device and automatically open it as well.