Skip to content

Commit 02e3441

Browse files
authored
fixed an issue with null schedule mode for older notifications scheduled using periodicallyShow on Android (#2076)
1 parent 0a40eef commit 02e3441

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

flutter_local_notifications/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# [16.0.0-dev.2]
22

3+
* [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
34
* Updated example app so that the Android side specifies minimum SDK version version that aligns with what's specified by the Flutter SDK
45
* Fixed Dart API docs for `DarwinNotificationDetails` class where `this This` was being repeated. Thanks to the PR from [Adrian Jagielak](https://github.com/adrianjagielak)
56

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,14 @@ private static void repeatNotification(
673673
getBroadcastPendingIntent(context, notificationDetails.id, notificationIntent);
674674
AlarmManager alarmManager = getAlarmManager(context);
675675

676+
if (notificationDetails.scheduleMode == null) {
677+
// This is to account for notifications created in older versions prior to allowWhileIdle
678+
// being added so the deserialiser.
679+
// Reference to old behaviour:
680+
// https://github.com/MaikuB/flutter_local_notifications/blob/4b723e750d1371206520b10a122a444c4bba7475/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java#L642
681+
notificationDetails.scheduleMode = ScheduleMode.inexact;
682+
}
683+
676684
if (notificationDetails.scheduleMode.useAllowWhileIdle()) {
677685
setupAllowWhileIdleAlarm(
678686
notificationDetails, alarmManager, notificationTriggerTime, pendingIntent);
@@ -1613,7 +1621,7 @@ private void getCallbackHandle(Result result) {
16131621
result.success(handle);
16141622
}
16151623

1616-
/// Extracts the details of the notifications passed from the Flutter side and also validates that
1624+
// Extracts the details of the notifications passed from the Flutter side and also validates that
16171625
// some of the details (especially resources) passed are valid
16181626
private NotificationDetails extractNotificationDetails(
16191627
Result result, Map<String, Object> arguments) {

0 commit comments

Comments
 (0)