I am working on To Do Flutter app, and I am trying to implement flutter_local_notifications package, I made two simple functions, showSimpleNotification() to show simple notification and scheduleNotification() for scheduling notification after 5 seconds, the simple one works just fine but the scheduling one not working, is everything ok with the code?
static Future showSimpleNotification({
required String title,
required String body,
required String payload,
}) async {
const AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails('your channel id', 'your channel name',
channelDescription: 'your channel description', importance: Importance.max, priority: Priority.high, ticker: 'ticker');
const NotificationDetails notificationDetails = NotificationDetails(android: androidNotificationDetails);
await _flutterLocalNotificationsPlugin.show(
0,
title,
body,
notificationDetails,
payload: payload,
);
}
static Future scheduleNotification({
required String title,
required String body,
required String payload,
}) async {
tz.initializeTimeZones();
await _flutterLocalNotificationsPlugin.zonedSchedule(
2,
title,
body,
tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5)),
const NotificationDetails(
android: AndroidNotificationDetails(
'channel 3',
'your channel name',
channelDescription: 'your channel description',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker',
),
),
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime,
payload: payload,
);
}