Skip to content

Commit

Permalink
fixed an issue with null schedule mode for older notifications schedu…
Browse files Browse the repository at this point in the history
…led using periodicallyShow on Android (#2076)
  • Loading branch information
MaikuB committed Aug 24, 2023
1 parent 8732a53 commit 7611102
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# [14.1.3]

* * Updated example app so that the Android side specifies minimum SDK version version that aligns with what's specified by the Flutter SDK
* Fixed Dart API docs for `DarwinNotificationDetails` class where `this This` was being repeated. Thanks to the PR from [Adrian Jagielak](https://github.com/adrianjagielak)
* Updated example app so that the Android side specifies minimum SDK version version that aligns with what's specified by the Flutter SDK
* [Android] fixed issue an issue similar to [2033](https://github.com/MaikuB/flutter_local_notifications/issues/2033) that was addressed in 15.0.1 where notifications on scheduled using older version of the plugin via the `periodicallyShow()` method 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
* Updated example app so that the Android side specifies minimum SDK version version that aligns with what's specified by the Flutter SDK

# [14.1.2]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,14 @@ private static void repeatNotification(
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#L642
notificationDetails.scheduleMode = ScheduleMode.inexact;
}

if (notificationDetails.scheduleMode.useAllowWhileIdle()) {
setupAllowWhileIdleAlarm(
notificationDetails, alarmManager, notificationTriggerTime, pendingIntent);
Expand Down Expand Up @@ -1602,7 +1610,7 @@ private void getCallbackHandle(Result result) {
result.success(handle);
}

/// Extracts the details of the notifications passed from the Flutter side and also validates that
// Extracts the details of the notifications passed from the Flutter side and also validates that
// some of the details (especially resources) passed are valid
private NotificationDetails extractNotificationDetails(
Result result, Map<String, Object> arguments) {
Expand Down

0 comments on commit 7611102

Please sign in to comment.