watchOS.ts
Purpose
This module delivers core body temperature predictions to a paired Apple Watch using react-native-watch-connectivity. It attempts a foreground message first and falls back to background user-info transfer if the watch is not reachable.
Its responsibilities include:
- Sending a
{ event, value }payload to the watch viasendMessage - Falling back to
transferUserInfowhen the watch is out of foreground range - Logging the outcome of both delivery paths
Invariants
Foreground-First, Background Fallback
sendMessage is always attempted first.
If it fails (watch not reachable, app not in foreground on watch side), the error callback immediately calls transferUserInfo with the same payload. transferUserInfo queues the data for delivery when the watch is next reachable.
Fire-and-Forget
sendCBTToWatchOS returns void and does not await the delivery outcome.
Callers in predictionHeatRisk.ts do not need to await this function; a failed delivery is logged but does not block the prediction result.
Payload Shape
{ event: 'message', value: coreTempC }
Exports
sendCBTToWatchOS(...)
function sendCBTToWatchOS(coreTempC: number): void
Sends the core body temperature to the paired Apple Watch. Logs the delivery outcome. Never throws.
Parameters
| Parameter | Description |
|---|---|
coreTempC | Predicted core temperature in °C |