notifications.ts

Configures the notification handler and sends heat-risk alerts keyed to core temperature

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 setNotificationHandler at 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.5Life-threatening; instructs to call 119
≥ 40.0Call 119; apply ice packs
≥ 38.5Stop work; move to cool place
≥ 38.0Slow 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

ParameterDescription
riskTempPredicted core temperature in °C