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.
-
Create a new application:
cordova create SampleApp com.example.sampleapp videoconferencing -
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 ioscordova platform add android -
Add the EnableX plugin to your project:
cordova plugin add enablex-cordova-plugin
Set up for Android
-
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 androidionic cordova platform add android -
Set the minimum SDK version and perform desugaring in the
gradle.properties
file as shown below.android.useAndroidX = trueandroid.enableJetifier = truecdvMinSdkVersion = 21android.enableDexingArtifactTransform.desugaring = false -
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.32006cordova.system.library.8=io.socket:socket.io-client:1.0.0 -
If you encounter the following "merge debug resource failed" error, add
packagingOptions
in the app-levelbuild.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. -
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
-
Add the iOS project.
ionic cordova platform add ioscordova platform add iosNote: This command will install all EnableX dependency libraries through Pod.
-
Go to your iOS project folder and open xcode.
-
Set up the certificate.
-
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 ioscordova run android
Try the Sample Application
-
Clone or download the GitHub repository containing the sample 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 the platform (Android or iOS) for which you want to create the application.
cordova platform add iOS //add iOS to your projectcordova 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 Servervar password = 'PASSWORD' // HTTP Basic Auth Password of App Servervar kBaseURL = 'FQDN' // FQDN of App Server URL -
For Android only: Enable Multidex by running the following commands:
cordova plugin add cordova-plugin-enable-multidex -
Run the application on the platform that you added.
cordova run ios // to run iOS projectcordova 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
Parameter | Type | Description |
---|---|---|
errorCode | Number | Returns an error code depending on the error encountered. |
msg | String | Returns an error message depending on the error encountered. |
desc | String | Optional. 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.