# iOS SDK

# Installation

# Requirements

  • Xcode 12.4 or greater
  • Support for iOS 13+

# Swift Packages

The iOS SDK is available as a Swift Package and can be added to an Xcode project as a package dependency using File > Swift Packages > Add Package Dependency and entering the following package URLs:

# Realtime SDK

https://github.com/ATOS-VIRTUAL-CARE/vcs-realtime-sdk-ios

# WebRTC

https://github.com/ATOS-VIRTUAL-CARE/webrtc-ios

# Apollo

https://github.com/ATOS-VIRTUAL-CARE/apollo-ios

Also, when the Apollo package is imported, only select the following package products:

  • Apollo
  • ApolloAPI
  • ApolloWebSocket

# Examples

To include the iOS SDK in your project, add the following import line at the beginning of the source file that will use the SDK.

import VcsRealtimeSdk

# Join Room

Joining a room is how your program will interact with other participants, and allows video and audio to be sent and received from the client.

// Instantiate the realtime SDK
let realtime = RealtimeSDK(delegate: <object implementing RealtimeSDKProtocol>)

let roomHost = "<vcs-domain>/websocket/realtime/websocket"
let userName = "Test User"

var options = RealtimeSDK.RoomOptions(host: roomHost, name: userName)
options.audio = true
options.video = true
options.hdVideo = true

RealtimeSDK.joinRoom(token: token, options: options) { error in
    if let error = error {
        Logger.debug(logTag, "Error in joinRoom, error = \(error.localizedDescription)")
    }
}

If the joinRoom function is successful, the RealtimeSDKProtocol will provide a callback (onRoomInitialized) with a Room object. This object can be used to access room-specific functions such as mute/unmute, etc.

# Don't ask for camera/mic until other participant(s) joined

...
options.delayLocalStream = true

RealtimeSDK.joinRoom(token: token, options: options) { error in
    ...
}

# Mute/unmute

// Toggle the microphone mute status
// Returns true if the client is muted
let muteStatus = room.toggleMute()

# Switch Camera

Switch between the front and back camera for local video.

room.switchCamera()

# Toggle video

room.toggleVideo()

# Toggle audio

toggleAudio will add or remove an audio MediaStreamTrack in the local MediaStream. This is different from toggleMute, which simply enables/disables the existing audio track.

room.toggleVideo()

# Leave the Room

room.leaveRoom()

# Logging

The application can capture the SDK-generated log messages and print them to the console by implementing the RealtimeSDKLogProtocol as follows:

class MyLogger: RealtimeSDKLogProtocol {
    func logEvent(message: String) {
        print(message)
    }
}

...

let logger = MyLogger()
realtime.subscribeLogEvents(delegate: logger, severity: LogSeverity.debug)