1

我正在使用 flutter_local_notifications 来显示通知。我可以看到同一天的通知,但随着日期的变化,我看不到任何通知。

  static void showScheduledNotification(
  {int id = 0, String title, String body, String payload, Time time, List<int> days}) async {
print(time.hour.toString() + " : hour time");
print(days.toString() + " : minute time");

_notification.zonedSchedule(
    id,
    title,
    body,
    _scheduleWeekly(time, days: days),
    await _notificationDetails(),
    payload: payload,
  androidAllowWhileIdle: true,
    uiLocalNotificationDateInterpretation:
        UILocalNotificationDateInterpretation.absoluteTime,
    matchDateTimeComponents: DateTimeComponents.dayOfWeekAndTime,
    );

}

 static tz.TZDateTime _scheduleWeekly(Time time, {List<int> days}) {
tz.TZDateTime scheduledDate = _scheduleDaily(time);
while (!days.contains(scheduledDate.weekday)) {
  scheduledDate = scheduledDate.add(Duration(days: 1));
}
return scheduledDate;

}

4

0 回答 0