UXKit Voxeet Cordova

UXKit Voxeet Cordova

This plugin bridges the VoxeetUXKit library. Wait for deviceReady event before you interact with the plugin.

Before the installation, it is mandatory to add the following platforms:

  • iOS cordova platform add ios
  • Android cordova platform add android

Installation

cordova plugin add cordova-plugin-voxeet

Note: in some cases, it is needed to initialize the SDK beforehand. Especially in cases a plugin used by the application is delaying the onDeviceReady event.

cordova plugin add cordova-plugin-voxeet --variable VOXEET_CORDOVA_CONSUMER_KEY="your key" --variable VOXEET_CORDOVA_CONSUMER_SECRET="your secret"

iOS

  • after cordova platform add ios in the project root folder
  • set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES in Xcode build settings to true

To enable VoIP notification, follow https://voxeet.com/documentation/uxkit/swift#project-setup

Android

To enable push notification, follow the steps in the app, for push notification, follow https://github.com/voxeet/android-sdk-sample

  • Verify that the Voxeet Push Notification services's tags are before the other services registered in the AndroidManifest with the proper priority to prevent Cordova's FCM issues
  • You also need to make a modification in the generated MainActivity. Using Android Studio or any other IDE:

right before the call to super.onCreate(savedInstanceState);:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
);

This call use the following import: import android.view.WindowManager;

  • in order to implement properly the push notification, you also need to register the default accepted view if you changed its name. Edit the AndroidManifest.xml file and put this xml node in the :

    <meta-data android:name="voxeet_incoming_accepted_class" android:value="fully.qualified.package.name.to.the.default.cordova.activity" />

Implementation

Usage

The project is now exporting various elements to help integrate calls into your app

Before using the Voxeet singleton, you must use projection to have access to it:

const { Voxeet, UserType } = VoxeetSDK;

Import

You can use the Voxeet and UserInfo classes using the following:

  • Voxeet is a singleton from which you will interact with the SDK
  • UserInfo is a class:

    • constructor: (externalId: string, name: string, avatarUrl: string)
    • json(): return the corresponding json

Initialize

Voxeet.initialize(<consumer_key>: string, <secret_key>: string)
.then(() => {
  //if the initialization is ok
})
.catch(err => {
  //in case of error
});

Initialize with OAuth2

Voxeet.initializeWithRefresh(accessToken: string, refreshToken: () => Promise<boolean>)

//the refresh token callback to be used
const refreshToken = () => {
    return new Promise((resolve, reject) => {
    cordovaHTTP.get("https://YOUR_REFRESH_TOKEN_URL", null, {}, function(response) {
      var json = undefined;
      try { json = JSON.parse(response.data); } catch(e) { json = response; };
      resolve(json.access_token) //return your access token
    }, function(response) {
      alert('error ' + response.error);
    });
  });
}

//the actual call to the SDK initialization
refreshToken()
.then(result => Voxeet.initializeToken(result, refreshToken))
.then(() => {
  //if the initialization is ok
})
.catch(err => {
  //in case of error
});

Connect / Disconnect a session

Connect a session using the following code:

var user = new UserInfo(<externalId>: string, <name>: string, <avatarUrl>: string);

Voxeet.connect(user)
.then(() => {
  //if the session is connected
})
.catch(err => {
  //in case of error
});

Disconnect a session using the following code:

Voxeet.disconnect()
.then(() => {
  //if the session is disconnected
})
.catch(err => {
  //in case of error
});

Create / Join / Invite / Leave a conference

You can create a conference with a custom alias (optional). You can also invite others to join the current conference by using the invite method.

var user1 = new UserInfo(<externalId>: string, <name>: string, <avatarUrl>: string);
var user2 = new UserInfo(<externalId>: string, <name>: string, <avatarUrl>: string);
var user3 = new UserInfo(<externalId>: string, <name>: string, <avatarUrl>: string);

Voxeet.create({conferenceAlias: 'YOUR_CONFERENCE_ALIAS'})
.then(result => Promise.all([
  Voxeet.join(result.conferenceId),
  result.isNew ? Voxeet.invite(result.conferenceId, [user1, user2, user3]) : null
]))
.catch(err => {
  //in case of error
});

An other example if you don't want to invite anyone and a conference alias isn't needed.

Voxeet.create({})
.then(result => Promise.all([
  Voxeet.join(result.conferenceId)
]))
.catch(err => {
  //in case of error
});

To leave a conference, use the following code:

Voxeet.leave()
.then(() => {
  //call made and everything is ok
})
.catch(err => {
  //in case of error
});

Broadcast a message

To broadcast a message, use the following code:

Voxeet.sendBroadcastMessage('YOUR_MESSAGE')
.then(() => {
  //message sent
})
.catch(err => {
  //error while sending the message
});

Useful methods

To maximize or minimize a conference, use the appearMaximized (as in the example below). By default, the conference appears maximized. Change the value to false if you wish to minimize it.

Voxeet.appearMaximized(true)

To start a conference using a built-in receiver or a built-in receiver speaker, use the defaultBuiltInSpeaker (as in the example below). By default, the conference starts using a built-in receiver. Change the value to true if you wish to use built-in speaker.

Voxeet.defaultBuiltInSpeaker(true)

To enable a video, use the defaultVideo (as in the example below). By default, the conference starts without a video. Change the value to true if you wish to enable video conferencing.

Voxeet.defaultVideo(true)

Cordova example

var user1 = new UserInfo('0', 'Benoit', 'https://cdn.voxeet.com/images/team-benoit-senard.png');
var user2 = new UserInfo('1', 'Stephane', 'https://cdn.voxeet.com/images/team-stephane-giraudie.png');
var user3 = new UserInfo('2', 'Thomas', 'https://cdn.voxeet.com/images/team-thomas.png');

Voxeet.initialize('YOUR_CONSUMER_KEY', 'YOUR_CONSUMER_SECRET')
.then(() => Voxeet.appearMaximized(true))
.then(() => Voxeet.defaultBuiltInSpeaker(true))
.then(() => Voxeet.defaultVideo(true))
.then(() => Voxeet.connect(user1))
.then(() => Voxeet.create({conferenceAlias: 'YOUR_CONFERENCE_ALIAS', params: {videoCodec: 'H264'}}))
.then(result => Promise.all([
  Voxeet.join(result.conferenceId),
  result.isNew ? Voxeet.invite(result.conferenceId, [user2, user3]) : null
]))
.then(() => Voxeet.sendBroadcastMessage('Hello world'))
.then(() => Voxeet.leave())
.then(() => Voxeet.disconnect())
.then(() => alert("done"))
.error(err => alert(err));

Examples of starting Broadcasting / Webinar mode

(only compatible with Android) To start a webinar or broadcast mode conference:

Creating a conference

const options: = {
  alias: "some_alias",
  params: {
    liveRecording: true
  }
}

const promise = Voxeet.create(options);
//resolving

Joining a conference

const promise = Voxeet.broadcast(conferenceId);
//resolving

Enabling Android push notification

Add the following preference at the end of the config.xml file to enable Android push notifications:

<widget>
  <every other="tags" />
  <preference name="VOXEET_CORDOVA_USE_PUSH" value="true" />
</widget>

Android Q breaking changes

Previously given as an option, due to new mechanisms preventing standard behaviour, Android Q+ needs the following modification done:

<config-file parent="./application" target="AndroidManifest.xml">
  <meta-data android:name="voxeet_incoming_accepted_class" android:value="fully.qualified.package.name.to.the.default.cordova.activity" />
</config-file>

If this is not set, a caught-exception will be set in the logs.

Supported Platforms

  • iOS
  • Android

License

   Copyright 2020 - Voxeet

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.