Real-time bluetooth device data
Access real-time data on your device using Thryve SDK. Users simply connect their BLE device with Bluetooth broadcasting capabilities. Once connected, the data flows instantly to your mobile application, provided the connection is active.
Enhance your health or fitness application with easy access to real-time data using the Thryve SDK. Users can effortlessly connect their devices that support Bluetooth broadcasting and your application will have real-time data available, provided the connection is active.
Use the real-time heart rate and other data types availability via Thryve to build experiences for fitness enthusiasts to optimize their workouts using instantaneous heart rate feedback or allow for real-time heart rate monitoring in medical use-cases for improved care journeys.
Connect BLE Device
Please refer to the direct bluetooth device connection documentation for information on how to connect a BLE device.
Access real-time data
Capture live data via the onDeviceReadingReceived event in ThryveDeviceEventListener. This event provides immediate access to data from connected heart rate monitors and garmin devices.
import ThryveCore
import ThryveCommons
import ThryveBLE
class BLEViewModel: ObservableObject, ThryvDeviceEventListener {
---
//onDeviceReadingReceived method is a ThryveDeviceEventListener event listener callback.
//It is automatically triggered by ThryveSDK each time a ThryveDevice is connected
//The data recorded by BLE device is shared with the host application
func onDeviceReadingReceived(device: ThryveDevice, dataType: any ThryveDataType, response: ThryveResponse<ThryveDeviceReading>) {
guard let reading = response.data else {
if let error = response.errors?.first {
// Process all [ThryveErrors] in response.errors
}
return
}
let isGarmin = device.source == .garminCompanion
Task { @MainActor in
if isGarmin {
switch reading.item {
case .heartRate(let hr): self.garminLatestHR = hr.beatsPerMinute
case .spo2(let s): self.garminLatestSpO2 = s.spo2Reading.map { Double($0) }
case .beatToBeatInterval(let b): self.garminLatestBBI = b.bbi
case .respiration(let r): self.garminLatestRespiration = r.breathsPerMinute
case .stress(let s): self.garminLatestStress = s.stressScore
case .steps(let s): self.garminLatestSteps = s.steps
case .calories(let c): self.garminLatestCalories = c.activeCalories ?? c.totalCalories
case .floorsClimbed(let f): self.garminLatestFloors = f.floorsClimbed
case .bodyBattery(let b): self.garminLatestBodyBattery = b.bodyBatteryLevel
case .intensityMinutes(let i): self.garminLatestIntensityMinutes = i.dailyIntensityMinutes
case .bloodGlucose: break
@unknown default:
break
}
} else {
switch reading.item {
case .heartRate(let hr):
self.bleLatestHR = hr.beatsPerMinute
case .bloodGlucose(let g):
self.bleLatestGlucose = String(format: "%.1f %@", g.value, g.unit)
default:
break
}
}
}
}
---
}Data of connected devices is periodically uploaded to the Thryve backend in batches, rather than in real-time. This approach ensures persistent data storage while minimizing network and battery usage on devices.
Last updated

