Skip to content

Commit dd71cac

Browse files
authored
[flutter_local_notifications] fixed issue with null schedule mode where recurring notifications would fail to be scheduled as a result (#2041)
* fixed issue with null schedule mode * Google Java Format * added more details on explanation of how null schedule mode occurred --------- Co-authored-by: github-actions <>
1 parent 5c277d3 commit dd71cac

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

flutter_local_notifications/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [15.0.1]
2+
3+
* [Android] Fixed issue [2033](https://github.com/MaikuB/flutter_local_notifications/issues/2033) where notifications on scheduled using older version of the plugin would fail to have the next subsequent ones scheduled. This issue started occuring in 14.0 where support for inexact notifications was added using the `ScheduleMode` enum that was added and resulted in the deprecation of `androidAllowWhileIdle`. A mechanism was added to help "migrate" old notifications that had `androidAllowWhileIdle` specified but didn't account for how there are recurring notifications that were scheduled using older versions of the plugin prior to `androidAllowWhile` being added
4+
15
# [15.0.0]
26

37
* **Breaking change** removed deprecated `schedule()`, `showDailyAtTime()` and `showWeeklyAtDayAndTime()` methods. Notifications that were scheduled prior to this release should still work

flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,13 @@ private static void scheduleNextRepeatingNotification(
584584
PendingIntent pendingIntent =
585585
getBroadcastPendingIntent(context, notificationDetails.id, notificationIntent);
586586
AlarmManager alarmManager = getAlarmManager(context);
587+
if (notificationDetails.scheduleMode == null) {
588+
// This is to account for notifications created in older versions prior to allowWhileIdle
589+
// being added so the deserialiser.
590+
// Reference to old behaviour:
591+
// https://github.com/MaikuB/flutter_local_notifications/blob/4b723e750d1371206520b10a122a444c4bba7475/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java#L569C37-L569C37
592+
notificationDetails.scheduleMode = ScheduleMode.exactAllowWhileIdle;
593+
}
587594

588595
setupAllowWhileIdleAlarm(
589596
notificationDetails, alarmManager, notificationTriggerTime, pendingIntent);

flutter_local_notifications/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flutter_local_notifications
22
description: A cross platform plugin for displaying and scheduling local
33
notifications for Flutter applications with the ability to customise for each
44
platform.
5-
version: 15.0.0
5+
version: 15.0.1
66
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
77
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues
88

0 commit comments

Comments
 (0)