From 6de5fbe99167a5210211041b293f4d54584b6c71 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 28 Sep 2026 03:43:27 -0700 Subject: [PATCH] main, ensure the notifications permission is requested. --- lib/main.dart | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index badec0e..1bf930f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -173,7 +173,15 @@ class _HomeScreenState extends State { Timer? _alarmTimer; Future _scheduleAlarm() async { - // Ensure that Android has the correct permissions enabled. + // Get the Notifications permission: + final android = + _notifications + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin + >(); + await android?.requestNotificationsPermission(); + + // Ensure that Android has the correct alarm permissions. final canSchedule = await android?.canScheduleExactNotifications(); if (canSchedule != true) { _showSnack('Permissions not yet granted, requesting...'); @@ -243,7 +251,12 @@ class _HomeScreenState extends State { uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, ); - _showSnack('Alarm scheduled.'); + _showSnack('Alarm scheduled!'); + debugPrint('DEBUG: Alarm time: ${tzAlarm.toString()}'); + debugPrint('DEBUG: Current time: ${DateTime.now().toUtc().toString()}'); + debugPrint('DEBUG: ${_notifications.toString()}'); + + debugPrint('alarm: $tzAlarm, now: ${tz.TZDateTime.now(tz.local)}'); } else { _showSnack('Platform not detected, unsure how to show alarm.'); }