notificationService.ts
Configures the notification handler and sends heat-risk alerts keyed to a normalized risk level
Purpose
This module configures the global Expo notification handler and exposes functions for requesting notification permissions and sending heatstroke risk alerts. Unlike notifications.ts, alert content is determined by a normalized risk level value rather than a raw core temperature.
Its responsibilities include:
- Installing the global
setNotificationHandlerat module load time - Requesting foreground notification permissions from the user
- Scheduling an immediate local notification with a risk-level-appropriate message
- Mapping a normalized risk level to one of three 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, delivering alerts immediately.
Risk Level Thresholds
| Risk level | Message |
|---|---|
≥ 0.75 | Extreme risk |
≥ 0.50 | High risk |
< 0.50 | Normal risk |
Exports
requestNotificationPermissions()
async function requestNotificationPermissions(): Promise<boolean>
Requests notification permissions. Returns true if granted.
sendHeatstrokeAlert(...)
async function sendHeatstrokeAlert(riskLevel: number): Promise<void>
Schedules an immediate local notification with a message appropriate to the given normalized risk level.
Parameters
| Parameter | Description |
|---|---|
riskLevel | Normalized heat risk value in [0.0, 1.0] |