main, ensure the notifications permission is requested.

This commit is contained in:
me committed 2026-09-28 03:43:27 -07:00
1 parent 9ac5fdd4f6
commit 6de5fbe991
1 file changed
+15 -2
+15 -2
View File
@@ -173,7 +173,15 @@ class _HomeScreenState extends State<HomeScreen> {
Timer? _alarmTimer;
Future<void> _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<HomeScreen> {
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.');
}