From 64cc9ac9ac1923c64acf99d79c5cefd0aa4238fc Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Wed, 5 Jul 2023 18:52:32 +1000 Subject: [PATCH] [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 <> --- flutter_local_notifications/CHANGELOG.md | 4 ++++ .../FlutterLocalNotificationsPlugin.java | 7 +++++++ flutter_local_notifications/pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index 9305cbe25..bb8a9d6cb 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,3 +1,7 @@ +# [14.1.2] + +* [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 + # [14.1.1] * Fixed typo in API docs for the deprecated `showDailyAtTime()` method. Thanks to the PR from [Yuichiro Kawano](https://github.com/yu1ro) diff --git a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index 4e2195843..3430c8ae3 100644 --- a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -584,6 +584,13 @@ private static void scheduleNextRepeatingNotification( PendingIntent pendingIntent = getBroadcastPendingIntent(context, notificationDetails.id, notificationIntent); AlarmManager alarmManager = getAlarmManager(context); + if (notificationDetails.scheduleMode == null) { + // This is to account for notifications created in older versions prior to allowWhileIdle + // being added so the deserialiser. + // Reference to old behaviour: + // https://github.com/MaikuB/flutter_local_notifications/blob/4b723e750d1371206520b10a122a444c4bba7475/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java#L569C37-L569C37 + notificationDetails.scheduleMode = ScheduleMode.exactAllowWhileIdle; + } setupAllowWhileIdleAlarm( notificationDetails, alarmManager, notificationTriggerTime, pendingIntent); diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index dc4d34664..819bb77f8 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_local_notifications description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 14.1.1 +version: 14.1.2 homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues