feat:增加通知库的版本
This commit is contained in:
@@ -17,9 +17,6 @@ class NotifyService {
|
||||
|
||||
late FlutterLocalNotificationsPlugin _notifications;
|
||||
|
||||
// 使用绝对时间(而不是相对时间),避免时区转换问题。
|
||||
final dateInterpretation = UILocalNotificationDateInterpretation.absoluteTime;
|
||||
|
||||
// Android特殊模式,即使设备处于省电模式也能准时触发。
|
||||
final scheduleMode = AndroidScheduleMode.exactAllowWhileIdle;
|
||||
|
||||
@@ -29,7 +26,6 @@ class NotifyService {
|
||||
|
||||
// 初始化时区
|
||||
tz.initializeTimeZones();
|
||||
// String timeZoneName = await FlutterNativeTimezone.getLocalTimezone();
|
||||
tz.setLocalLocation(tz.getLocation("Asia/Shanghai"));
|
||||
|
||||
// 设置Android平台的初始化配置 使用应用图标作为通知图标
|
||||
@@ -66,11 +62,11 @@ class NotifyService {
|
||||
TodoSortMode.priority,
|
||||
);
|
||||
final List<Todo> todayTodos =
|
||||
todoResult
|
||||
.where(
|
||||
(todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime),
|
||||
)
|
||||
.toList();
|
||||
todoResult
|
||||
.where(
|
||||
(todo) => !todo.isCompleted && isAfterToday(todo.scheduledTime),
|
||||
)
|
||||
.toList();
|
||||
|
||||
for (Todo todo in todayTodos) {
|
||||
await scheduleNotification(
|
||||
@@ -84,9 +80,9 @@ class NotifyService {
|
||||
CalendarService calendarService = CalendarService();
|
||||
final List<Calendar> calendarResult = calendarService.getAllCalendars();
|
||||
final List<Calendar> todayCalendars =
|
||||
calendarResult
|
||||
.where((item) => isAfterToday(item.scheduledTime))
|
||||
.toList();
|
||||
calendarResult
|
||||
.where((item) => isAfterToday(item.scheduledTime))
|
||||
.toList();
|
||||
|
||||
for (Calendar calendar in todayCalendars) {
|
||||
await scheduleNotification(
|
||||
@@ -152,7 +148,6 @@ class NotifyService {
|
||||
body,
|
||||
tz.TZDateTime.from(scheduledTime, tz.local),
|
||||
_details,
|
||||
uiLocalNotificationDateInterpretation: dateInterpretation,
|
||||
androidScheduleMode: scheduleMode,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user