scheduleNotification method
Schedules a notification with id, title, and body at the schedule time.
If the id is not specified, a random id will be generated.
Returns the id of the notification created.
Implementation
@override
Future<int> scheduleNotification({int? id, required String title, String? body, required DateTime schedule}) async {
tz.initializeTimeZones(); // for some strange reason, the time zones are not always initialized when this method is called, so we initialize them here to be sure
id ??= _random.nextInt(1000);
final time = tz.TZDateTime.from(schedule, tz.getLocation(Settings().timezone));
await FlutterLocalNotificationsPlugin().zonedSchedule(
id: id,
title: title,
body: body,
scheduledDate: time,
notificationDetails: _platformChannelSpecifics,
androidScheduleMode: await _scheduleMode,
);
return id;
}