The EnableX Cordova Plugin is designed to integrate EnableX RTC sessions into Hybrid Mobile Applications such as Cordova, PhoneGap, and Ionic. The Plugin consists of APIs required to communicate with EnableX Signaling Server and Media Server and to listen to event-based notifications during a session.

Table of Contents

How to use EnableX Cordova Plugin

Creating a New Application using EnableX Cordova Plugin

  • Create a new application
cordova create SampleApp com.example.sampleapp videoconferencing
  • Add Platform
cordova platform add ios cordova platform add android
  • Add EnableX Plugin into your Project
cordova plugin add enablex-cordova-plugin
  • Set up Cordova/Ionic application on Android using the following steps:
  • Step 1: Go inside the Cordova project and open the Android folder

If the Android platform already added, remove Android and add again using the below command

ionic cordova platform rm android && ionic cordova platform add android 
  • Step 2: Set the Minimum SDK version and desugaring in gradle.properties file as shown: 
android.useAndroidX=true 
android.enableJetifier=true 
cdvMinSdkVersion=21 
android.enableDexingArtifactTransform.desugaring=false 
  • Step 3: Add the required libraries like webrtc and socket in the project. properties file as shown:
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: If you face a “merge debug resource failed” error, then add packagingOptions in the app-level build.gradle file in android block 
Execution failed for task ':app:mergeDebugJavaResource'. 

> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 

   > More than one file was found with OS independent path 'META-INF/DEPENDENCIES'. 
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")  
      } 
  • Set up Cordova/Ionic on iOS using the following steps:
  • Step 1: Add iOS project 
ionic cordova platform add ios/ cordova platform add ios 

This installs all dependency EnableX libraries through Pod.  

  • Step 2: Go to your iOS project folder and open xcode. 
  • Step 3: Set up your certificate.  
  • Step 4: Build the app either through command line or through xcode.
  • Build application
cordova build
  • Run the application
cordova run ios
cordova run android

Try the Sample Application demonstrating EnableX Cordova Plugin

  • Clone or download Repository for Demo Application
  • Go to the terminal and change your directory to the root of the sample project that you want to run.
  • Install the required node modules
npm install
  • Add required Platforms (Android or iOS)
cordova platform add iOS //add iOS to your project
cordova platform add android //add android to your project
  • Configure the following variables before running the application
var userName = "USERNAME"; /* HTTP Basic Auth Username of App Server */
var password = "PASSWORD"; /* HTTP Basic Auth Password of App Server */
var kBaseURL = "FQDN" /* FQDN of App Server URL */
  • For Android only: Enable Multidex
cordova plugin add cordova-plugin-enable-multidex
  • Run the application
cordova run ios // to run iOS project
cordova run android // to run Android project

Device Permission

Setup for iOS

Open the info.plist and add:

  • Privacy – Microphone Usage description and add a note in the Value column.
  • Privacy – Camera Usage description and add a note in the Value column.

Error & Exceptions

Cordova SDK method call might face exception cases and fail. In such cases a JSON is returned through Callback. Example of JSON Object given below:

{
	"errorCode": Number,
	"msg": "String",
	"desc": "String"
}
  • errorCode– Number. Error Code.
  • msg – String. Error Message.
  • desc – String. Optional. Descriptive explanation of the error.

Explore Cordova SDK