Skip to content

Commit

Permalink
[flutter_local_notifications] fixed issue with null schedule mode whe…
Browse files Browse the repository at this point in the history
…re 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 <>
  • Loading branch information
MaikuB committed Jul 5, 2023
1 parent 553d5fb commit 64cc9ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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)
Expand Down
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/pubspec.yaml
Expand Up @@ -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

Expand Down

0 comments on commit 64cc9ac

Please sign in to comment.