warm_alarm_macos

style: very good analysis License: BSD-3-Clause

The macOS implementation of warm_alarm.

This package is endorsed, which means you do not add it directly to your pubspec.yaml. It is automatically included when you depend on warm_alarm.


Platform capabilities

Feature Support Notes
Notification scheduling ✅ Full UNUserNotificationCenter
Exact alarm scheduling ❌ None Not supported; scheduling is notification-based only
Background audio playback ⚠️ Limited AVAudioPlayer only; no AVAudioSession on macOS
Full-screen presentation ❌ None macOS does not support full-screen intent notifications
Wake-check ❌ None macOS cannot self-trigger background wakes after dismissal

⚠️ Limited means alarms fire via UNUserNotificationCenter notifications. Audio plays when the user clicks the notification or when the app is in the foreground. Unlike iOS, macOS has no AVAudioSession category override, so Silent mode behavior is governed by the system audio stack without the plugin's intervention.


Native implementation

Scheduling

Alarms are scheduled as UNNotificationRequest objects via UNUserNotificationCenter, using a UNCalendarNotificationTrigger for the configured scheduledAt time.

Audio

WarmAlarmDelegate plays audio with AVAudioPlayer. Because macOS does not expose AVAudioSession, the plugin cannot guarantee audio playback when the system or app volume is muted. An optional fade-in is applied by scheduling discrete volume steps as DispatchWorkItems (via DispatchQueue.main.asyncAfter), not a periodic timer.

Recurrence

Weekly recurrence is delivered natively: one UNCalendarNotificationTrigger(repeats: true) is registered per selected weekday, matching DateComponents(weekday, hour, minute), keyed "{id}#{isoWeekday}". The series recurs without any re-arm and survives app termination. ISO weekdays (1 = Mon … 7 = Sun) are mapped to Apple's Calendar weekdays (1 = Sun … 7 = Sat). Dismissing an alarm ends only the current occurrence; cancelAlarm(id) removes every per-weekday request and tears down the series.

Kill warning

setKillWarning(title, body) posts a persistent notification reminding users not to force-quit the app before an alarm fires. clearKillWarning() removes it.

Events emitted

macOS emits the same subset of events as iOS:

  • WarmAlarmScheduled
  • WarmAlarmFired
  • WarmAlarmStopped
  • WarmAlarmSnoozed
  • WarmAlarmFailed

Wake-check events are not supported on macOS.


Pigeon wire layer

All Dart ↔ Swift communication is generated by Pigeon. The schema lives in pigeons/messages.dart; generated outputs (Messages.g.swift, lib/src/messages.g.dart) are never hand-edited. Run melos run generate after any schema change.


License

BSD-3-Clause — Copyright (c) 2026, Dongmin Yu. See LICENSE for details.

Libraries

warm_alarm_macos