Cordova / Ionic Video SDK
The EnableX Cordova plugin integrates EnableX real-time video sessions into hybrid mobile applications built with Cordova, PhoneGap, and Ionic. The plugin communicates with EnableX Signaling and Media servers and surfaces event-based notifications throughout the session lifecycle — all from a single JavaScript codebase that targets both iOS and Android.
- Available on npm → enablex-cordova-plugin
- Supports iOS and Android from one codebase
- Language: JavaScript (Cordova plugin pattern)
- Global entry point:
window.EnxRtc
The Cordova plugin is installed into a Cordova project using the standard CLI. You can start a fresh project or add the plugin to an existing one.
Create a New Project
Use the Cordova CLI to scaffold the project, add your target platforms, then install the EnableX plugin:
# 1. Scaffold a new Cordova application
cordova create SampleApp com.example.sampleapp videoconferencing
# 2. Add your target platforms
cordova platform add ios
cordova platform add android
# 3. Install the EnableX Cordova plugin
cordova plugin add enablex-cordova-plugin
Android Setup
After adding the Android platform, a few Gradle configuration changes are required to satisfy the WebRTC and socket dependencies the SDK relies on.
Step 1 — Re-add the Android platform if it was already present:
ionic cordova platform rm android
ionic cordova platform add android
Step 2 — In gradle.properties, set the minimum SDK and enable AndroidX:
android.useAndroidX = true
android.enableJetifier = true
cdvMinSdkVersion = 21
android.enableDexingArtifactTransform.desugaring = false
Step 3 — In project.properties, add the required WebRTC and socket libraries:
cordova.system.library.7=org.webrtc:google-webrtc:1.0.32006
cordova.system.library.8=io.socket:socket.io-client:1.0.0
Step 4 — Resolve merge conflicts (if needed). If your build fails with
"More than one file was found with OS independent path META-INF/DEPENDENCIES", add
packagingOptions inside the android { } block of your app-level
build.gradle:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
iOS Setup
Adding the iOS platform automatically installs EnableX dependency libraries through CocoaPods. After that you only need to set up your signing certificate and build.
# Add iOS platform (triggers pod install automatically)
ionic cordova platform add ios
# or
cordova platform add ios
# Open Xcode, set up your signing certificate, then build
cordova build
Info.plist and add the following two keys with
user-facing description strings. Without them the app will crash when requesting camera or microphone access.
NSCameraUsageDescription— explain why the app needs the cameraNSMicrophoneUsageDescription— explain why the app needs the microphone
Run the Application
cordova run ios
cordova run android
The entire SDK surface is exposed through the global object window.EnxRtc. Every SDK
action is a method call on this object, and every asynchronous result arrives through an event listener
registered with window.EnxRtc.addEventListner().
Calling Methods
Methods accept parameters and optional success/error callbacks. They initiate an action and the result arrives asynchronously through the associated event listener:
// Moderator starts recording
window.EnxRtc.startRecord();
// Listen for the confirmation
window.EnxRtc.addEventListner("onStartRecordingEvent", function(data) {
console.log(JSON.stringify(data.data));
});
Registering Event Listeners
Register your event listeners before calling joinRoom(). Events such as
onRoomConnected and onPublishedStream fire immediately when the session
connects — adding listeners afterwards risks missing the first notification.
// Register listeners first
window.EnxRtc.addEventListner("onRoomConnected", function(data) {
console.log("Room connected:", JSON.stringify(data.data));
initLocalView();
initRemoteView();
});
window.EnxRtc.addEventListner("onRoomError", function(data) {
console.error("Connection error:", JSON.stringify(data.data));
});
// Then join the room
window.EnxRtc.joinRoom(token, streamOpt, roomOpt,
function(data) { /* success */ },
function(err) { /* error */ }
);
Error and Exception Handling
When an SDK method call fails, the error is delivered through the errorCallback or the
relevant failure event as a JSON object with this shape:
{
"errorCode": 1182,
"msg": "Failed to upload the file.",
"desc": "Storage quota exceeded on the EnableX server."
}
| Field | Type | Description |
|---|---|---|
errorCode | Number | Numeric code identifying the failure type |
msg | String | Short human-readable error message |
desc | String | Optional longer description of the error |
A working one-to-one video chat sample is available on GitHub. Clone it, configure your App Server credentials, and run it on either platform to see the full connection flow in action.
# 1. Clone the sample
git clone https://github.com/EnableX/One-to-One-Video-Chat-Sample-Cordova-Application
# 2. Install node modules
npm install
# 3. Add your platforms
cordova platform add ios
cordova platform add android
# 4. Edit the app — set your App Server credentials
# var userName = 'USERNAME' // HTTP Basic Auth username
# var password = 'PASSWORD' // HTTP Basic Auth password
# var kBaseURL = 'FQDN' // Your App Server FQDN
# 5. Android only: enable Multidex
cordova plugin add cordova-plugin-enable-multidex
# 6. Run
cordova run ios
cordova run android
The Cordova SDK documentation is split into focused sub-sections. Follow them in order for a guided integration: