main, ensure the notifications permission is requested.
This commit is contained in:
1 parent
9ac5fdd4f6
commit
6de5fbe991
1 file changed
+15
-2
+15
-2
@@ -173,7 +173,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Timer? _alarmTimer;
|
Timer? _alarmTimer;
|
||||||
|
|
||||||
Future<void> _scheduleAlarm() async {
|
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();
|
final canSchedule = await android?.canScheduleExactNotifications();
|
||||||
if (canSchedule != true) {
|
if (canSchedule != true) {
|
||||||
_showSnack('Permissions not yet granted, requesting...');
|
_showSnack('Permissions not yet granted, requesting...');
|
||||||
@@ -243,7 +251,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
uiLocalNotificationDateInterpretation:
|
uiLocalNotificationDateInterpretation:
|
||||||
UILocalNotificationDateInterpretation.absoluteTime,
|
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 {
|
} else {
|
||||||
_showSnack('Platform not detected, unsure how to show alarm.');
|
_showSnack('Platform not detected, unsure how to show alarm.');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user