iOS SDK

Voxeet SDK logo

The Voxeet SDK is a Swift library allowing users to:

  • Create demo/normal conferences
  • Join conferences
  • Change sounds angle and direction for each conference user
  • Broadcast messages to other participants
  • Send and receive video stream

Table of contents

  1. Requirements
  2. Sample Application
  3. Installing the iOS SDK
  4. SDK Initialization
  5. SDK Usage
  6. VTAudioSound Usage
  7. Available delegates / callbacks

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Sample Application

A sample application is available on this public repository on GitHub.

Installing the iOS SDK

You need to disable Bitcode in your Xcode target settings: 'Build Settings' -> 'Enable Bitcode' -> No

To enable background mode, go to your target settings -> 'Capabilities' -> 'Background Modes'
Turn on 'Audio, AirPlay and Picture in Picture'
Turn on 'Voice over IP'

Installation with CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate VoxeetSDK into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

target "YourTarget" do
       pod 'VoxeetSDK', '~> 1.0'
end

Then, run the following command:

$ pod install

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate VoxeetSDK into your Xcode project using Carthage, specify it in your Cartfile:

github "voxeet/ios-sdk-sample" ~> 1.0

Run carthage update to build the framework and drag the built VoxeetSDK.framework into your Xcode project.

SDK Initialization

Initialize the SDK in the AppDelegate.swift of your application:

import VoxeetSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        // Initialization of the Voxeet SDK.
        VoxeetSDK.sharedInstance.initializeSDK("consumerKey", consumerSecret: "consumerSecret")

        return true
    }

    ...
}

SDK Usage

Initializing

VoxeetSDK.sharedInstance.initializeSDK("consumerKey", consumerSecret: "consumerSecret")

If you use external login like O365, LDAP, or custom login to retrieve contact details it's now possible to also add your contact ID with the display name and the photo URL avatar.
This allows you to ask guest users to introduce themselves and provide their display name and for your authenticated users in your enterprise or for your clients the ID that can be retrieved from O365 (name, department, etc).

VoxeetSDK.sharedInstance.initializeSDK("consumerKey", consumerSecret: "consumerSecret", externalID: "ID", name: "name", avatarURL: "URL")

Creating a demo conference

VoxeetSDK.sharedInstance.conference.createDemo { (error) in 
}

Creating a conference

VoxeetSDK.sharedInstance.conference.create(success: { (confID, confAlias) in
    }, fail: { (error) in
})

Joining a conference

VoxeetSDK.sharedInstance.conference.join(conferenceID: confID) { (error) in
}
VoxeetSDK.sharedInstance.conference.join(conferenceAlias: confAlias) { (error) in
}

Leaving a conference

VoxeetSDK.sharedInstance.conference.leave { (error) in
}

Getting a specific conference status

VoxeetSDK.sharedInstance.conference.status(conferenceID: "", success: { (json) in
    }) { (error) in
}

Getting own users

let ownUser = VoxeetSDK.sharedInstance.conference.getOwnUser()

Getting current conference users

let users = VoxeetSDK.sharedInstance.conference.getUsers()

Getting a specific user's information

let infos = VoxeetSDK.sharedInstance.conference.getUserInfo("userID")

Changing user position

// Values for angle and distance are between: angle = [-1, 1] and distance = [0, 1]
VoxeetSDK.sharedInstance.conference.setUserPosition("userID", angle: 0, distance: 0)
VoxeetSDK.sharedInstance.conference.setUserAngle("userID", angle: 0)
VoxeetSDK.sharedInstance.conference.setUserDistance("userID", distance: 0)

Getting a specific user position

let (angle, distance) = VoxeetSDK.sharedInstance.conference.getUserPosition("userID")

Sending broadcast message in a conference

VoxeetSDK.sharedInstance.conference.sendBroadcastMessage("message", completion: { (error) in
})

Muting / Unmuting a user

VoxeetSDK.sharedInstance.conference.muteUser("userID", mute: true)

Checking if a user is muted

let isMute = VoxeetSDK.sharedInstance.conference.isUserMuted("userID")

Changing output device

if VoxeetSDK.sharedInstance.conference.setOutputDevice(VTOutputDeviceType.BuildInReceiver) {
    print("The output device has been changed.")
}

Getting output devices

let (currentOutputDevice, availableOutputDevices) = VoxeetSDK.sharedInstance.conference.getOutputDevices()

Connecting the SDK with the API (manually)

This optional method is automatically called before a regular request anyway. For example 'createDemoConference' calls internally 'connect'.

VoxeetSDK.sharedInstance.connect { (error) in
}

Disonnecting the SDK with the API (manually)

This optional method can help to disconnect the SDK if you don't use it anymore.

VoxeetSDK.sharedInstance.disconnect { (error) in
}

Available delegates / callbacks

Session

class myClass: VTSessionStateDelegate {
    init() {
        // Session delegate.
        VoxeetSDK.sharedInstance.sessionStateDelegate = self
    }

    func sessionStateChanged(state: VTSessionState) {
    }
}

or

VoxeetSDK.sharedInstance.sessionStateChanged = { state in
}

Conference

class myClass: VTConferenceDelegate {
    init() {
        // Conference delegate.
        VoxeetSDK.sharedInstance.conference.delegate = self
    }

    func userJoined(userID: String, userInfo: [String: AnyObject]) {
    }

    func userLeft(userID: String, userInfo: [String: AnyObject]) {
    }

    func messageReceived(userID: String, userInfo: [String: AnyObject], message: String) {
    }
}

or

VoxeetSDK.sharedInstance.conference.userJoined = { (userID, userInfo) in
}

VoxeetSDK.sharedInstance.conference.userLeft = { (userID, userInfo) in
}

VoxeetSDK.sharedInstance.conference.messageReceived = { (userID, userInfo, message) in
}

Conference media (video, screenshare)

class myClass: VTConferenceMediaDelegate {
    @IBOutlet weak var videoRenderer: VideoRenderer!

    init() {
        // Conference media delegate.
        VoxeetSDK.sharedInstance.conference.mediaDelegate = self
    }

    func streamAdded(stream: MediaStream, peerID: String) {
        // Attaching a video stream to a renderer.
        VoxeetSDK.sharedInstance.conference.attachMediaStream(videoRenderer, stream: stream)
    }

    func streamRemovedForPeer(peerID: String) {
    }

    func streamScreenShareAdded(stream: MediaStream, peerID: String) {
        // Attaching a video stream to a renderer.
        VoxeetSDK.sharedInstance.conference.attachMediaStream(videoRenderer, stream: stream)
    }

    func streamScreenShareRemoved(peerID: String) {
    }
}

or

VoxeetSDK.sharedInstance.conference.streamAdded = { (stream: MediaStream, peerID: String) in
}

VoxeetSDK.sharedInstance.conference.streamRemoved = { (peerID: String) in
}

VoxeetSDK.sharedInstance.conference.streamScreenShareAdded = { (stream: MediaStream, peerID: String) in
}

VoxeetSDK.sharedInstance.conference.streamScreenShareRemoved = { (peerID: String) in
}

Available enums

Session state:

public enum VTSessionState {
    case NotConnected
    case Connected
    case Connecting
    case Reconnecting
}

Output devices:

public enum VTOutputDeviceType: Int {
    case BuildInReceiver
    case BuiltInSpeaker
    case Headset
    case LineOut
    case Bluetooth
    case CarAudio
    case HDMI
    case AirPlay
}

Error handler:

public enum VTErrorType: ErrorType {
    case Credential(String)
    case InternalServer
    case AccessToken
    case NoLiveConference
    case LeaveConference
    case CreateConference
    case JoinConference
    case SendBroadcastMessage
    case ServerError(String?)
    case Error(ErrorType?)
}

VTAudioSound Usage

VTAudioSound helps you to play a TrueVoice 3D audio sound into your application.
The sound must be encoded in mono to be played spatialized.

Initializing

var sound: VTAudioSound?

if let path = NSBundle.mainBundle().pathForResource("myFile", ofType: "mp3") {
    do {
        sound = try VTAudioSound(url: NSURL(fileURLWithPath: path))
    } catch let error {
        // Debug.
        print("::DEBUG:: \(error)")
    }
}

Playing sound

try? sound?.play() {
    // Debug.
    print("::DEBUG:: The sound has finished being played.")
}

Stopping sound

sound?.stop()

Checking if the sound is playing

let isPlaying = sound?.isPlaying

Looping on the current sound

sound?.loop = true

Getting filename of the sound

let filename = sound?.filename

Setting / Getting volume

// The range of valid values are from 0.0 to 1.0.
sound?.volume = 1
let volume = sound?.volume

Setting / Getting angle

// The range of valid values are from -1.0 to 1.0.
sound?.angle = 0
let angle = sound?.angle

Setting / Getting distance

// The range of valid values are from 0.0 to 1.0.
sound?.distance = 0
let distance = sound?.distance

Version

1.0.1.9

Tech

The Voxeet iOS SDK uses a number of open source projects to work properly:

  • Starscream - Starscream is a conforming WebSocket (RFC 6455) client library in Swift for iOS and OSX.
  • Alamofire - Alamofire is an HTTP networking library written in Swift.
  • SwiftyJSON - SwiftyJSON makes it easy to deal with JSON data in Swift.
  • CryptoSwift - Crypto related functions and helpers for Swift implemented in Swift.

© Voxeet, 2016