enableBackgroundDelivery

actual suspend fun enableBackgroundDelivery(onDataAvailable: () -> Unit?)

Enables platform-specific background delivery of health data.

  • iOS/watchOS: Registers an HKObserverQuery for step-count data and enables HealthKit background delivery (approximately hourly).

  • Android: Schedules a periodic WorkManager sync (approximately every hour).

Parameters

onDataAvailable

Optional callback invoked when new health data becomes available (e.g. when an HKObserverQuery fires on iOS). On Android, the WorkManager worker calls syncSteps() directly, so this callback is not used.

actual suspend fun enableBackgroundDelivery(onDataAvailable: () -> Unit?)

Enables HealthKit background delivery for step-count data.

When enabled, iOS will wake the app periodically (approximately hourly) when new step data is written to HealthKit.

Prerequisites:

  • com.apple.developer.healthkit.background-delivery entitlement

  • UIBackgroundModes includes fetch in Info.plist

  • HealthKit permissions must already be granted

Call disableBackgroundDelivery to stop.

actual suspend fun enableBackgroundDelivery(onDataAvailable: () -> Unit?)

Enables HealthKit background delivery for step-count data.

When enabled, watchOS will wake the app periodically (approximately hourly) when new step data is written to HealthKit. Each wake-up emits a Unit on healthDataUpdates.

Call disableBackgroundDelivery to stop.