Skip to content

Monitor heart rate

The base HealthBridge plugin observes heart-rate data through the active health provider. HealthKit, Health Connect, and connected devices can synchronize samples after recording, so this path does not guarantee live timing.

  1. Enable read permission for Heart Rate.
  2. Get HealthBridgeSubsystem and bind On Heart Rate Updated.
  3. Initialize HealthBridge.
  4. Check the provider’s heart-rate capability.
  5. Call Start Heart Rate Monitoring.
  6. Update transient UI when the event provides a sample.
  7. Call Stop Heart Rate Monitoring when the owning screen, actor, or game mode ends.
#include "HealthBridgeEvents.h"
#include "HealthBridgeService.h"
FDelegateHandle HeartRateHandle = FHealthBridgeEvents::OnHeartRateUpdated.AddLambda(
[](const FHealthBridgeHeartRateSample& Sample)
{
const double BeatsPerMinute = Sample.BeatsPerMinute;
// Update transient gameplay or UI state.
});
if (TSharedPtr<IHealthBridgeProvider> Provider = FHealthBridgeService::GetProvider())
{
Provider->StartHeartRateMonitoring([](bool bStarted) {});
}

Stop monitoring and remove delegates when their owner is destroyed.

  • Show the sample timestamp, not just BPM.
  • Mark stale values as stale instead of presenting them as current.
  • Handle long periods without a sample.
  • Keep gameplay usable when heart rate is unavailable.
  • Do not treat synchronization timing as a fixed polling guarantee.

Do not send BPM, timestamps, source labels, raw callbacks, or record IDs to analytics, crash reports, general logs, or support tickets. Keep only the data required by the feature and follow the product’s consent and retention policy.

The editor mock proves that your event and UI paths work. Physical-device testing is still required for permissions, synchronization, backgrounding, and real provider behavior.

See device validation before release.