Installation
Requirements: iOS 14.0+, Xcode 15.0+, Swift 5.7+
The iOS SDK ships as pre-built frameworks. Add them to your Xcode target:
| Framework | Action |
|---|
PlaudBleSDK.framework | Embed & Sign |
PlaudWiFiSDK.framework | Embed & Sign |
PlaudDeviceBasicSDK.framework | Embed & Sign |
PlaudDeviceBasicSDK.bundle | Copy Bundle Resources |
Frameworks are located at sdk/ios/ in the plaud-template-app repository.
SDK frameworks are compiled for arm64 (physical devices only). Simulator is not supported.
Android SDK is coming soon.
Initialization
The SDK is initialized with a user access token and your server domain. Mint the user token on your backend before calling initSDK — see Transcription API → Authentication for the token exchange flow. Never embed your secret_key in the app.
import PlaudDeviceBasicSDK
PlaudDeviceAgent.shared.initSDK(
userAccessToken: "your-jwt-token",
customDomain: "platform-us.plaud.ai" // domain only, no https://
)
| Parameter | Required | Description |
|---|
userAccessToken | Yes | User Access Token (JWT). Used for device authentication. The handshake token is automatically parsed from the JWT sub field. |
customDomain | Yes | Server domain without https:// prefix. All SDK network requests use this domain. |
Dynamic Token Refresh
When the User Access Token is refreshed (e.g., after re-login), update it:
PlaudDeviceAgent.shared.setUserAccessToken(newToken)
This automatically updates the handshake token and refreshes the RSA key pair.
Device Connection
PlaudDeviceAgent.shared.delegate = self
PlaudDeviceAgent.shared.startScan()
PlaudDeviceAgent.shared.connectBleDevice(bleDevice: device)
Key Callbacks (PlaudDeviceAgentProtocol)
| Callback | Description |
|---|
bleScanResult(bleDevices:) | Scan results updated |
bleConnectState(state:) | 1 = connected, 0 = disconnected |
bleBind(sn:status:...) | Device bound successfully |
blePenState(state:...) | Handshake complete (state = 4099 means recording active) |
File Synchronization
// Get file list from device
PlaudDeviceAgent.shared.getFileList(startSessionId: 0)
// Export audio file (supports .pcm, .wav, .opus)
PlaudDeviceAgent.shared.exportAudio(
sessionId: sessionId,
outputDir: outputDir,
format: .opus,
channels: 1,
callback: self
)
// Delete file from device
PlaudDeviceAgent.shared.deleteFile(sessionId: sessionId)
WiFi Fast Transfer
~10x faster than BLE. Requires the Hotspot Configuration entitlement.
PlaudDeviceAgent.shared.setDeviceWiFi(open: true)
// In bleWiFiOpen callback:
PlaudWiFiAgent.shared.bleDevice = BleAgent.shared.bleDevice
PlaudWiFiAgent.shared.connectWifi(ssid, password, 60)
// After wifiHandshake(status: 0):
PlaudWiFiAgent.shared.exportAudioViaWiFi(...)
Firmware Update (OTA)
SDK handles the entire OTA flow: version query → download → MD5 verify → CRC → BLE packet push → device restart → reconnect.
// Check for update
PlaudDeviceAgent.shared.checkFirmwareUpdate { result in
guard result.hasUpdate else { return }
print("New version: \(result.latestVersion), release notes: \(result.releaseNotes)")
}
// One-call firmware update
PlaudDeviceAgent.shared.startFirmwareUpdate(
progress: { phase, percentage in
// phase: .downloading / .installing / .restarting / .complete
// percentage: 0.0 ~ 1.0
},
completion: { result in
if result.success {
print("Updated to \(result.version)")
} else {
print("Failed: \(result.errorMessage ?? "")")
}
}
)
If you already have the firmware file downloaded, use pushFirmwareFile() instead:
PlaudDeviceAgent.shared.pushFirmwareFile(
filePath: localPath,
toVersion: "V1.2.8",
progress: { phase, pct in },
completion: { result in }
)