# Examples for Cordova
The examples are projects of cross-platform Cordova applications. Each example consists of three parts: the Android part, the iOS part, and the shared JS code.
The Android section contains a project for Android Studio IDE;
The iOS section contains a project for Xcode IDE;
The JS part includes the UI, core logic code, and SDK usage code.
To get started with TrueConf Mobile SDK, you need to install the SDK NuGet package:
let sdkBuilder = cordova.require('trueconf-sdk-plugin.sdk');
sdkBuilder.getInstance("qa.trueconf.net").then(instance => {
sdk = instance; // save the SDK instance for further use
}, error => {
console.log(error);
});
The SDK initialization is performed by calling the start
function. Following the initialization, event handling is configured in the onSDKReady
method using the addEventListener
function:
onSDKReady: function() {
sdk.addEventListener("onLogin", this.onLogin.bind(this));
sdk.addEventListener("onLogout", this.onLogout.bind(this));
sdk.addEventListener("onServerStatus", this.onServerStatus.bind(this));
sdk.addEventListener("onInvite", this.onInvite.bind(this));
}
The iOS project is ready to use. Simply open the xcworkspace
file in Xcode from the platforms/ios
folder.
The Android project requires additional configuration: you need to specify the repository address and add calls to the registerApp
and setFallbackActivity
methods (more details are described here).
# Example 1. Demonstration of the main capabilities of the SDK
A single-page application where all the main features of TrueConf Mobile SDK are implemented:
Initialization and server connection (
start
).Tracking client statuses.
Connect to the server, log in as a user and log out by pressing the corresponding buttons.
Call a user by their TrueConf ID (
callTo
).Ability to receive incoming video calls.
The event signifies the ability to start working with TrueConf Mobile SDK:
Processing events:
LOGOFF
(0) — the user is not connected to the serveronLogin
- tracking login status;onLogout
- tracking logout status;onInvite
- processing incoming calls and invitations to a group conference.
By clicking on the corresponding buttons, the methods are invoked:
start
- SDK initialization;loginAs
- authentication with TrueConf ID and password;login
– user ID (string);callTo
- call the user whose TrueConf ID is entered in the corresponding input field.
# Example 2. Demonstration of working with TrueConf links
A single-page application where all the main features of TrueConf Mobile SDK are implemented:
Initialization and server connection (
start
).Processing the entered trueconf link upon button click.
The event signifies the ability to start working with TrueConf Mobile SDK:
Processing events:
LOGOFF
(0) — the user is not connected to the serverCamera status change.
onLogin
- tracking login status;onLogout
- tracking logout status;onInvite
- processing incoming calls and invitations to a group conference.
By clicking on the corresponding buttons, the methods are invoked:
start
- SDK initialization;parseProtocolLink
- execution of a sequence of commands from a TrueConf link.
# Example 4. Working with User Statuses
The example provides a working code sample that allows you to monitor the statuses of users on the server with whom you can establish a connection, as well as add any users to track their statuses and monitor their availability. In addition to the user status itself, the standard functionality of TrueConf Mobile SDK is used: server connection, login, and automatic call acceptance.
The entire operation of the example is based on a single event handler block, onUserStatusUpdate
, which executes when the server sends the status of a user. To add any user to the tracking list, the getUserStatus
method is used. The implemented code allows monitoring and displaying changes in the status of a specific user in a table, handling the addition of new users, and adding any user for tracking.
A single-page application where all the main features of TrueConf Mobile SDK are implemented:
Checking another user's status and receiving change notifications
Adding users to the watchlist by their TrueConf ID.
Joining a group conference.
Display a list of users with their statuses from the address book and watch list.
Ability to receive incoming video calls.
The event signifies the ability to start working with TrueConf Mobile SDK:
Processing events:
LOGOFF
(0) — the user is not connected to the serveronLogin
- tracking login status;onLogout
- tracking logout status;onInvite
- handles incoming calls and invitations to join a group conference;onUserStatusUpdate
- tracking changes in user statuses from the address book or watchlist.
By clicking on the corresponding buttons, the methods are invoked:
start
- SDK initialization;loginAs
- authentication with TrueConf ID and password;login
– user ID (string);getUserStatus
- retrieves the user status and adds it to the watch list in the current session.
# Example 3. Working with group conferences
One of the key features of TrueConf Mobile SDK is the ability to participate in video conferences with multiple users simultaneously. Currently, it only allows joining existing conferences.
Joining a group conference.
Receiving an invitation via an incoming call, similar to a regular
onInvite
call withacceptCall
confirmation.By conference ID using the
joinConf
method.Via a TrueConf link that includes the conference ID using the method
parseProtocolLink
.Use the method
scheduleLoginAs
, passing the conference ID as thecallToUser
parameter and specifyingisPublic=true
. This method is similar to theparseProtocolLink
method but does not require knowledge of the command line format, providing a fixed set of parameters.
The event signifies the ability to start working with TrueConf Mobile SDK:
Processing events:
LOGOFF
(0) — the user is not connected to the serveronLogin
- tracking login status;onLogout
- tracking logout status;onInvite
- handles incoming calls and invitations to join a group conference;Checking conference presence.
Checking conference presence.
By clicking on the corresponding buttons, the methods are invoked:
start
- SDK initialization;loginAs
- authentication with TrueConf ID and password;login
– user ID (string);Connecting to the selected server
# Example 5. Interface Customization
The example demonstrates how you can add your own custom buttons and open your window on top of the conference window.
The general section duplicates the functionality of Example 1:
Connecting a participant.
Checking authorization status.
Call a user by their TrueConf ID (
callTo
).Handling of key events and monitoring of client status.
The example demonstrates the addition of a custom button and the display of a separate window over the conference window. The addExtraButton
function receives the name of the custom button, and then in the onExtraButtonPressed
event handler, the showAlertPage
function is called to display a new window over the conference window - Activity
for Android, UIViewController
for iOS. In this case, these windows are created and configured directly in the SDK plugin: for Android, it's the DialogActivity
class, for iOS, it's the DialogViewController
. These classes can be edited.
# Example 6. Chat
A single-page application where all the main features of TrueConf Mobile SDK are implemented:
Initialization and server connection (
start
).Tracking client statuses.
Connect to the server, log in as a user and log out by pressing the corresponding buttons.
Call a user by their TrueConf ID (
callTo
).Ability to receive incoming video calls.
The event signifies the ability to start working with TrueConf Mobile SDK:
Processing events:
LOGOFF
(0) — the user is not connected to the serveronLogin
- tracking login status;onLogout
- tracking logout status;onInvite
- handles incoming calls and invitations to join a group conference;onChatMessageReceived
- handles incoming chat messages. When a new text message arrives, an Alert appears displaying the message text and the sender's name.
By clicking on the corresponding buttons, the methods are invoked:
start
- SDK initialization;loginAs
- authentication with TrueConf ID and password;login
– user ID (string);sendChatMessage
- sends a chat message to the user whose TrueConf ID is entered in the corresponding input field.