notifications.ts
Purpose
This module configures the global Expo notification handler and exposes functions for requesting notification permissions and sending immediate heatstroke risk alerts. Alert message content is determined by core temperature thresholds.
Its responsibilities include:
- Installing the global
setNotificationHandlerat module load time - Requesting foreground notification permissions from the user
- Scheduling an immediate local notification with a temperature-appropriate message
- Mapping a core temperature value to one of four risk message strings
Invariants
Handler Installed at Import Time
Notifications.setNotificationHandler is called as a module-level side effect.
The handler always allows banner display, sound, and list display. Badge setting is always disabled.
Immediate Trigger
All notifications use trigger: null, meaning they are delivered immediately rather than scheduled for a future time.
Temperature-Based Message Selection
Alert messages are selected by descending threshold comparison against the same zone boundaries used in PredictionScreen:
| Core temp (°C) | Message severity |
|---|---|
≥ 40.5 | Life-threatening; instructs to call 119 |
≥ 40.0 | Call 119; apply ice packs |
≥ 38.5 | Stop work; move to cool place |
≥ 38.0 | Slow down; rest and hydrate |
< 38.0 | "safe" (no alert expected at this level) |
Exports
requestNotificationPermissions()
async function requestNotificationPermissions(): Promise<boolean>
Requests notification permissions. Returns true if granted.
sendHeatstrokeAlert(...)
async function sendHeatstrokeAlert(riskTemp: number): Promise<void>
Schedules an immediate local notification with a message appropriate to the given core temperature.
Parameters
| Parameter | Description |
|---|---|
riskTemp | Predicted core temperature in °C |