Bit6 with Cordova CLI

It is very easy to add Bit6 IP Messaging and WebRTC Voice/Video calling capabilities to your applications.

Prerequisites

Sample App

The easiest way to get started is using our demo application. Download or clone the demo app to a local directory:

git clone https://github.com/bit6/bit6-cordova-demo

Development

Set API Key

Edit www/js/index.js file to set your Bit6 API Key:

// Init Bit6 SDK
var opts = {'apikey': 'myApiKey'};

Set App ID

Edit ./config.xml file to set your app identifier

<widget id="com.bit6.samples.DemoApp" ... >
...
</widget>

NOTE: For iOS - make sure it matches the identifier you used for APNS registration.

Add Bit6 Plugin

Go to the project directory and type:

cordova plugin add https://github.com/bit6/bit6-cordova

Add Push Plugin

Push Notification support is required for receiving incoming calls and messages. Make sure appropriate push configuration is done in Bit6 Dashboard (see Prerequisites section).

Add one of the following push plugins to your project:

a. PhoneGap Push Plugin (recommended)

# Set any value for SENDER_ID. Bit6 plugin will override it with the correct one.
cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX"

b. Telerik Push Plugin

cordova plugin add https://github.com/Telerik-Verified-Plugins/PushNotification

c. Legacy PhoneGap Push Plugin - if you are using cordova-ios 3.x

iOS-only Settings

Voice/Video Call Support (optional)

To enable call support on iOS add iosrtc plugin

cordova plugin add cordova-plugin-iosrtc

Check iosrtc plugin requirements and build configurations.

You need to copy the provided hook to your project hooks directory, and add appropriate configuration to config.xml file.

<platform name="ios">
    <hook type="after_platform_add" src="hooks/iosrtc-swift-support.js" />
</platform>

Fixing Status Bar (optional)

In some iOS versions, the Cordova WebView may overlap the system status bar. This can be fixed by adding the following plugin:

# Add StatusBar plugin
cordova plugin add https://github.com/apache/cordova-plugin-statusbar

Android 4.x Settings

Voice/Video Call Support (optional)

To enable call support on Android prior to 5.0, add Crosswalk WebView plugin:

cordova plugin add cordova-plugin-crosswalk-webview

Older Android Devices

If your application needs to work on Android devices prior to 4.4, adding Crosswalk WebView plugin is mandatory.

Platforms

Add the platforms you want to support:

cordova platform add ios
cordova platform add android
cordova platform add browser

Build and Run

# Run on iOS device
cordova run ios --device
# Run on Android device
cordova run android --device
# Run in a browser
cordova run browser

Using Sample App

The sample application allows you to create users and let them send rich messages (text, photo, video) to each other as well as make voice and video calls.

Create a new user, or use an existing one.

IP Messaging

Create a new chat 'Direct' or 'Group'

In the chat screen you can make video/voice calls, send/receive text messages and attachments, see typing notifications.

Video/Voice Calling

Next Steps