Cordova SDK

The EnableX Cordova plugin is designed to integrate EnableX RTC sessions with hybrid mobile applications such as Cordova, PhoneGap, and Ionic. The plugin includes the APIs required to communicate with EnableX Signaling and Media servers and to listen to event-based notifications during a session.

How to use?

Use the Cordova plugin to create a new application.

  1. Create a new application:

    cordova create SampleApp com.example.sampleapp videoconferencing
  2. Add the platforms for which you want to create the new application. For example, iOS and Andriod, as specified in the below command.

    cordova platform add ios
    cordova platform add android
  3. Add the EnableX plugin to your project:

    cordova plugin add enablex-cordova-plugin

Set up for Android

  1. Open the Cordova project, then open the Android folder.

    Note: If the Android platform is already added, remove it and add it again using the following command:

    ionic cordova platform rm android
    ionic cordova platform add android
  2. Set the minimum SDK version and perform desugaring in the gradle.properties file as shown below.

    android.useAndroidX = true
    android.enableJetifier = true
    cdvMinSdkVersion = 21
    android.enableDexingArtifactTransform.desugaring = false
  3. Add the required libraries of WebRTC and socket in the project.properties file as shown below.

    cordova.system.library.7=org.webrtc:google-webrtc:1.0.32006
    cordova.system.library.8=io.socket:socket.io-client:1.0.0
  4. If you encounter the following "merge debug resource failed" error, add packagingOptions in the app-level build.gradle file in the 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.
  5. Add packagingOptions as shown below.

    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 for iOS

  1. Add the iOS project.

    ionic cordova platform add ios
    cordova platform add ios

    Note: This command will install all EnableX dependency libraries through Pod.

  2. Go to your iOS project folder and open xcode.

  3. Set up the certificate.

  4. Build the application either through the command line or through xcode.

    cordova build

Run the New Application

To run the new application on Android or iOS platforms, run the following commands for your platform:

cordova run ios
cordova run android

Try the Sample Application

  1. Clone or download the GitHub repository containing the sample application.

  2. Go to the terminal and change your directory to the root of the sample project that you want to run.

  3. Install the required node modules:

    npm install
  4. Add the platform (Android or iOS) for which you want to create the application.

    cordova platform add iOS //add iOS to your project
    cordova platform add android //add android to your project
  5. 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
  6. For Android only: Enable Multidex by running the following commands:

    cordova plugin add cordova-plugin-enable-multidex
  7. Run the application on the platform that you added.

    cordova run ios // to run iOS project
    cordova run android // to run Android project

Device Permissions

For iOS, open info.plist and add two new entries with the following keys:

  • NSCameraUsageDescription
  • NSMicrophoneUsageDescription

Add user-facing strings explaining why your application needs camera and microphone access as the value of these keys.

Error and Exception Handling

When an SDK method call encounters an issue and fails, a JSON object containing the details of the error is returned through callback. Below is an example of this JSON object.

{
"errorCode": Number,
"msg": "String",
"desc": "String"
}

JSON Explaination

ParameterTypeDescription
errorCodeNumberReturns an error code depending on the error encountered.
msgStringReturns an error message depending on the error encountered.
descStringOptional. Returns explanation of the error encountered.

SDK Methods

The SDK provides several methods for implementing different features and functionalities.

For more information, see List of SDK Methods.

Media Devices

The SDK provides several methods to access device cameras and microphones that can be used to create media streams to publish into the video rooms.

For more information, see Get Media Devices.

Stream Configuration

The SDK supports the following stream configurations:

Room Connection

The SDK provides several methods for connecting virtual video rooms.

For more information, see Room Connection.

Room Information

The SDK provides several methods to obtain virtual room configuration and connection information including Room ID, room mode, if the room is connected, details of connected users such as User ID, Client ID, and role, list of connected users, and local stream configuration.

For more information, see Get Room Information.

In-session Communication

The SDK provides several methods for managing in-session communication including chat, file sharing, custom signalling, screen sharing, canvas streaming, and annotations.

For more information, see In-Session Communication.

Session Management

The SDK provides several methods for managing different aspects of video sessions including recording a session, playing a recorded file, muting or unmuting a room, forcing room entry restrictions, disconnecting a user from a session, extending or concluding a session, and switching participant roles.

For more information, see Session Management.

Floor Access Control

Participants can request for floor access in the Lecture mode. The SDK provides different methods to implement floor access.

For more information, see Floor Access Control.

Configure View

The SDK provides several methods to hide or unhide local, screenshare, and canvas views, resize local and remote views, set a desired video quality, and adjust player layout.

For more information, see Configure View.

Live Statistics

The SDK provides several methods to obtain live statistics of local, remote, canvas streaming, and screen sharing during a session.

For more information, see Live Media Statistics.

Utilities

The SDK provides several methods for managing different aspects of video sessions through different utilities.

For more information, see Utilities.