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
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
- Value: viveglass-connect
- Key: NSBonjourServices
- Name: Bonjour services
- Value: _viveglass_connect._tcp
The following keys are required to connect to VIVE AI Glasses directly via Bluetooth.
- Key: NSBluetoothAlwaysUsageDescription
- Name: Privacy - Bluetooth Always Usage Description
- String suggestion: Communicate with VIVE AI glasses to sync the device status and receive and respond to user questions.
The following keys are required if your app needs to run in the background.
- Key: UIBackgroundModes
- Name: Required background modes
- Value: <array><string>bluetooth-central</string></array>
To ensure that that VIVE Connect can communicate with your app, add the following information to your Info.plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string> <!-- Replace with your unique scheme -->
</array>
</dict>
</array>
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)
}
Step 3: Handle authentication callback
Call the following from your app’s URL handler so the SDK can receive and process the authorization response. This returns true if the URL was consumed, and false if it wasn’t.
Usage (SwiftUI):
.onOpenURL { url in
if !ViveGlass.shared.handleAuthCallback(url) {
// handle other deep links}
}
Usage (UIKit / AppDelegate):
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if ViveGlass.shared.handleAuthCallback(url) { return true }
// handle other deep links
return false}