Setup
Configure your app and establish your first connection with VIVE AI Glasses.
Overview
Before you can communicate with VIVE AI Glasses, you need to configure your app’s permissions and initialize the SDK.
Step 1: Add the property list key
Since the glasses communicate via the local network (sockets), you must update your app’s Info.plist file and insert the following property list key to prevent crashes at runtime:
- Key: NSLocalNetworkUsageDescription
- Name: Privacy - Local Network Usage Description
- String suggestion: We use the local network to stream videos from VIVE AI Glasses.
The following keys are required if you are developing using a simulator. We use iPhone's capability to simulate the behavior of VIVE AI Glasses.
- Key: NSMicrophoneUsageDescription (optional, simulator only)
- Name: Privacy - Microphone Usage Description
- String suggestion: We use the microphone to transcribe your speech.
- Key: NSSpeechRecognitionUsageDescription
- Name: Privacy - Speech Recognition Usage Description
- String suggestion: We use speech recognition to convert your voice to text.
The following keys are required for your app to connect to VIVE AI Glasses. We use Bonjour service to provide connectivity.
- Key: LSApplicationQueriesSchemes
- Name: Queried URL Schemes
- String value: viveglass-connect
- Key: NSBonjourServices.
- Name: Bonjour services
- String value: _viveglass_connect._tcp
Step 2: Initialize the SDK
In your main view controller or app delegate, import the framework and then set up the delegate to receive events.
import UIKit
import ViveGlassKitclass ViewController: UIViewController, ViveGlassDelegate {
override func viewDidLoad() {
super.viewDidLoad()// 1. Set the delegate
ViveGlass.shared.delegate = self// 2. Connect
ViveGlass.shared.connect()
}// 3. ViveGlassDelegate Methods
func glasses(didUpdateConnectionState state: ViveGlass.ConnectionState) {
switch state {case .connected:
print("VIVE Glass connected!")
case .disconnected:
print("VIVE Glass disconnected.")
default:
break
}
}
// Implement other required delegate methods...
func glasses(didReceiveKeyEvent event: ViveGlass.KeyEvent)
func glasses(didReceiveTranscribedEvent event: ViveGlass.TranscribedEvent, text: String?)
func glasses(didReceiveSynthesisEvent event: ViveGlass.SynthesisEvent)
func glasses(didReceiveCaptureEvent event: ViveGlass.CaptureEvent, data: Data)
}