# Examples for .NET
The examples are cross-platform MAUI application projects based on .NET 8. Each example consists of three parts: the Android part, the iOS part, and the shared code (based on .NET 8).
The Android section of the project contains settings and platform-specific code for Android;
iOS part - accordingly iOS code and settings;
The section with shared code contains the UI, the core operational logic code, and the SDK usage code.
To use TrueConf Mobile SDK, you first need to import platform-specific interfaces in the App class:
using Trueconf.Sdk.NET;
#if ANDROID
using Trueconf.Sdk.Android;
#elif IOS
using Trueconf.Sdk.iOS;
#endif
All you need to get started is to obtain the ITrueConfSDK
object by initializing the implementation of this interface for Android or iOS:
ITrueConfSDK tcSDK = new TrueConfSDKAndroid(); // for Android
ITrueConfSDK tcSDK = new TrueConfSDKiOS(); // for iOS
All examples contain common parts:
- In the App class constructor, when creating a MainPage object, the received
ITrueConfSDK
object is passed to the MainPage constructor:
MainPage = new MainPage(tcSDK);
- In the MainPage constructor, the obtained
ITrueConfSDK
object is stored in the class fieldtcSDK
, and the handling of necessary events is configured.
tcSDK.OnServerStatusEvent += TrueConfSDK_OnServerStatusEvent; tcSDK.OnStateChangedEvent += TrueConfSDK_OnStateChangedEvent; tcSDK.OnLoginEvent += TrueConfSDK_OnLoginEvent; tcSDK.OnLogoutEvent += TrueConfSDK_OnLogoutEvent; tcSDK.OnInviteEvent += TrueConfSDK_OnInviteEvent; tcSDK.OnRejectEvent += TrueConfSDK_OnRejectEvent; tcSDK.OnRejectTimeOutEvent += TrueConfSDK_OnRejectTimeOutEvent; tcSDK.OnAcceptEvent += TrueConfSDK_OnAcceptEvent; tcSDK.OnConferenceEndEvent += TrueConfSDK_OnConferenceEndEvent; tcSDK.OnConferenceStartEvent += TrueConfSDK_OnConferenceStartEvent; tcSDK.OnUserStatusUpdateEvent += TrueConfSDK_OnUserStatusUpdateEvent;
The initial initialization occurs in platform-specific parts of the project with the passing of platform-dependent parameters -
Activity
for Android andUIApplication
for iOS. Then, theStart
method is called in the MainPage class, and the setup for handling necessary events in the example is located in the constructor of the MainPage class. Event handlers can also be configured afterStart
and can be changed at any time.Android part: In the
MainActivity
class, within theOnCreate
method, the static methodInit
is called, passing the currentActivity
for subsequent initialization:
TrueConfSDKAndroid.Init(this);
- iOS part: In the
AppDelegate
class, within theFinishedLaunching
method, the static methodInit
is called, passing the currentUIApplication
for subsequent initialization:
TrueConfSDKiOS.Init(application);
# 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 serverOnLoginEvent
- tracking login status;OnLogoutEvent
- tracking of the logout status;OnInviteEvent
- handling incoming calls and invitations for auto-answer;OnStateChangedEvent
- client state tracking.
By clicking on the corresponding buttons, the methods are invoked:
Start
- SDK initialization;LoginAs
- authentication using TrueConf ID and password;login
– user ID (string);CallTo
- call to the user whose TrueConf ID is entered in the corresponding input field.
The UpdateConnectionState method utilizes the following property methods:
IsStarted
- check if the SDK is running;LOGOFF
(0) — the user is not connected to the serverEvent triggered upon deauthorization on the server.
BUSY
(2) — the user is in a call or conference
# 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 serverOnStateChangedEvent
- client state tracking.
By clicking on the corresponding buttons, the methods are invoked:
SDK object initialization function.
ParseProtocolLink
- execution of a sequence of commands in a trueconf link.
The UpdateConnectionState method utilizes the following property methods:
LOGOFF
(0) — the user is not connected to the server
# 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, OnUserStatusUpdateEvent
, which is executed when the server sends a user's status. To add any user to the watch list, the GetUserStatus
method is used. The implemented code allows tracking and displaying changes in the status of a specific user in the table, handling the addition of new users, and adding any user for tracking.
To store the list of users with their statuses, the UserStatus
class is implemented with the fields string userId
, string status
, Color color
. This class implements the INotifyPropertyChanged
interface to support automatic table updates when there are changes in the user status list. In the MainPage class, there is a field containing a list of UserStatus
objects to store all tracked users and their statuses:
ObservableCollection<UserStatus> users;
In the constructor of the MainPage class, this list is passed as the ItemsSource
to a ListView element on the page for display.
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 serverOnLoginEvent
- tracking login status;OnLogoutEvent
- tracking of the logout status;OnInviteEvent
- handling incoming calls and invitations for auto-answer;OnStateChangedEvent
- tracking the client state;OnUserStatusUpdateEvent
- 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 using TrueConf ID and password;login
– user ID (string);GetUserStatus
- retrieves the user's status and adds it to the watch list in the current session.
The UpdateConnectionState method utilizes the following property methods:
IsStarted
- check if the SDK is running;LOGOFF
(0) — the user is not connected to the serverEvent triggered upon deauthorization on the server.
BUSY
(2) — the user is in a call or conferenceuserId
– TrueConf ID of the called user (string);
# 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 OnInviteEvent call with AcceptCall confirmation.
By conference ID using the method
JoinConf
.Via a TrueConf link that includes the conference ID using the
ParseProtocolLink
method.Use the method
ScheduleLoginAs
, passing the conference ID as thecallToUser
parameter and settingisPublic=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 serverOnLoginEvent
- tracking login status;OnLogoutEvent
- tracking of the logout status;OnInviteEvent
- handling incoming calls and invitations for auto-answer;OnStateChangedEvent
- client state tracking.
By clicking on the corresponding buttons, the methods are invoked:
Start
- SDK initialization;LoginAs
- authentication using TrueConf ID and password;login
– user ID (string);Connecting to the selected server
The UpdateConnectionState method utilizes the following property methods:
IsStarted
- check if the SDK is running;LOGOFF
(0) — the user is not connected to the serverEvent triggered upon deauthorization on the server.
BUSY
(2) — the user is in a call or conference
# Example 5. Interface Customization
The example demonstrates how to replace the images of all buttons displayed during a call, add your own custom buttons, and open your own 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.
Additionally, in the Android and iOS versions, implementation includes adding custom buttons and displaying a separate alert window over the conference window.
Android section:
After calling the Init
function in the OnCreate
method of the MainActivity class, an array of TCExtraButton
objects is created. You need to pass the button name and the action to be performed as Android.Views.View.IOnClickListener
:
var btns = new TCExtraButton[] {
new TCExtraButton("Button 1", new OnClickListener(handler: v => AlertCreate(1))),
...
};
The AlertCreate
function creates an AlertDialog
and is displayed using the Show
method:
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.SetPositiveButton("OK", (sender, e) => { });
dialog.SetCancelable(false);
dialog.SetTitle("Title");
dialog.SetMessage("Message");
dialog.Show();
Then, in the OnCreate
method of the MainActivity class, the created buttons are added to the SDK using the static method AddCustomButtons
:
TrueConfSDKAndroid.AddCustomButtons(btns);
iOS section:
After the Init
function is called in the FinishedLaunching
method of the AppDelegate class, an array of TCSDKExtraButton
objects is created, where a UIAlertController
is instantiated and displayed using the PresentViewController
method:
var btns = new UIAlertAction[] {
new TCSDKExtraButton("Button 1", UIImage.GetSystemImage("star"), () => {
var alertController = UIAlertController.Create("Title", "Message", UIAlertControllerStyle.Alert);
alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
TrueConfSDKiOS.PresentViewController(alertController, true, null, null);
}),
...
};
Then, in the FinishedLaunching
method of the AppDelegate class, after creating an array of buttons of type TCSDKExtraButton
, the created array is added to the SDK using the static method AddCustomButtons
:
TrueConfSDKiOS.AddCustomButtons(btns);
# 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 serverOnLoginEvent
- tracking login status;OnLogoutEvent
- tracking of the logout status;OnInviteEvent
- handling incoming calls and invitations for auto-answer;OnStateChangedEvent
- tracking the client state;OnChatMessageReceivedEvent
- 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 using 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.
The UpdateConnectionState method utilizes the following property methods:
IsStarted
- check if the SDK is running;LOGOFF
(0) — the user is not connected to the serverEvent triggered upon deauthorization on the server.
BUSY
(2) — the user is in a call or conference