Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_local_notifications] fixed an issue with null schedule mode for older notifications scheduled using periodicallyShow on Android #2076

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [16.0.0-dev.2]

* [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
* Fixed Dart API docs for `DarwinNotificationDetails` class where `this This` was being repeated. Thanks to the PR from [Adrian Jagielak](https://github.com/adrianjagielak)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,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 @@ -1613,7 +1621,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