Need help with zonedSchedule
This code works perfectly on my android app.
await flutterLocalNotificationsPlugin.show(
id, 'Task Reminder', 'Time to finish a task!',
platformChannelSpecifics,
payload: 'todo payload',
);
This code however, doesn't do anything, I tried a lot of things, but I can't figure out what it might be.
await flutterLocalNotificationsPlugin.zonedSchedule(
id, 'Task Reminder', 'Time to finish a task!',
// Notification in 5 seconds.
tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
platformChannelSpecifics,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
androidScheduleMode: AndroidScheduleMode
.alarmClock, // Ensure the notification is shown even if the phone is in a low-power idle mode
matchDateTimeComponents: DateTimeComponents
.time, // Match on time component only for daily recurrence
payload: 'todo payload',
);
This also does not display.
static Future<void> _zonedScheduleAlarmClockNotification() async {
await flutterLocalNotificationsPlugin.zonedSchedule(
123,
'scheduled alarm clock title',
'scheduled alarm clock body',
tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
const NotificationDetails(
android: AndroidNotificationDetails(
'alarm_clock_channel', 'Alarm Clock Channel',
channelDescription: 'Alarm Clock Notification')),
androidScheduleMode: AndroidScheduleMode.alarmClock,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime);
}
Did you check what the time tz.TZDateTime.now(tz.local) gives? I had this problem when my tz was not properly initialised, so before calling tz.local I had to make this:
tz.initializeTimeZones();
final String timeZoneName = await FlutterTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(timeZoneName));
I'm experiencing the same issue after updating to version 16.3.2 from version 13.0.0.
I have checked that my timezone is set correctly.
I also tried changing between absoluteTime and wallClockTime.
Found the culprit: from version 16.0.0, the plugin only specifies the bare minimum in AndroidManifest.xml, the rest has to be done by hand. This includes enabling scheduled notifications.
See the README: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications#androidmanifestxml-setup
Closing this as the OP didn't respond to others who offered help
Thank you all for helping out! Sorry for being unresponsive.