Skip to content

Commit 7611102

Browse files
committed
fixed an issue with null schedule mode for older notifications scheduled using periodicallyShow on Android (#2076)
1 parent 8732a53 commit 7611102

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

flutter_local_notifications/CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# [14.1.3]
22

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

67
# [14.1.2]
78

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,14 @@ private static void repeatNotification(
662662
getBroadcastPendingIntent(context, notificationDetails.id, notificationIntent);
663663
AlarmManager alarmManager = getAlarmManager(context);
664664

665+
if (notificationDetails.scheduleMode == null) {
666+
// This is to account for notifications created in older versions prior to allowWhileIdle
667+
// being added so the deserialiser.
668+
// Reference to old behaviour:
669+
// https://github.com/MaikuB/flutter_local_notifications/blob/4b723e750d1371206520b10a122a444c4bba7475/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java#L642
670+
notificationDetails.scheduleMode = ScheduleMode.inexact;
671+
}
672+
665673
if (notificationDetails.scheduleMode.useAllowWhileIdle()) {
666674
setupAllowWhileIdleAlarm(
667675
notificationDetails, alarmManager, notificationTriggerTime, pendingIntent);
@@ -1602,7 +1610,7 @@ private void getCallbackHandle(Result result) {
16021610
result.success(handle);
16031611
}
16041612

1605-
/// Extracts the details of the notifications passed from the Flutter side and also validates that
1613+
// Extracts the details of the notifications passed from the Flutter side and also validates that
16061614
// some of the details (especially resources) passed are valid
16071615
private NotificationDetails extractNotificationDetails(
16081616
Result result, Map<String, Object> arguments) {

0 commit comments

Comments
 (0)