0.1.2 #1
+15
-2
@@ -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.');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user