From 5375645b01c845998606b58a3d97b278c5b2cefa Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Mon, 6 May 2024 23:31:40 +1000 Subject: [PATCH] [flutter_local_notifications] coleasce null audio attributes when mapping notification channel (#2319) * coleasce null audio attributes when mapping notification channel * Google Java Format * fixed typo in changelog entry * fixed another issue with changelog entry where "error" was written instead of "occur" --------- Co-authored-by: github-actions <> --- flutter_local_notifications/CHANGELOG.md | 4 ++++ .../FlutterLocalNotificationsPlugin.java | 7 ++++++- flutter_local_notifications/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index 41744831b..b916750b4 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,3 +1,7 @@ +## [17.1.2] + +* [Android] fixed issue [2318](https://github.com/MaikuB/flutter_local_notifications/issues/2318) where an exception could occur on calling the `getNotificationChannels()` method from the `AndroidFlutterLocalNotificationsPlugin` class. This happened when Android found that the audio attributes associated with the channel was null. The plugin will now coalesce the null value to indicate that the usage of the audio is for notifications as per https://developer.android.com/reference/android/media/AudioAttributes#USAGE_NOTIFICATION. On the Dart side, this would correspond to the [AudioAttributesUsage.notification](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/AudioAttributesUsage.html#notification) enum value + ## [17.1.1] * [Android] fixes issue [#2299](https://github.com/MaikuB/flutter_local_notifications/issues/2299) where within the range of the max integer value of epoch time passed to a messaging style would result in a casting exception diff --git a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index ce86cc5ad..409a26a50 100644 --- a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -2081,7 +2081,12 @@ private HashMap getMappedNotificationChannel(NotificationChannel channelPayload.put("vibrationPattern", channel.getVibrationPattern()); channelPayload.put("enableLights", channel.shouldShowLights()); channelPayload.put("ledColor", channel.getLightColor()); - channelPayload.put("audioAttributesUsage", channel.getAudioAttributes().getUsage()); + final AudioAttributes audioAttributes = channel.getAudioAttributes(); + channelPayload.put( + "audioAttributesUsage", + audioAttributes == null + ? AudioAttributes.USAGE_NOTIFICATION + : audioAttributes.getUsage()); } return channelPayload; } diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index 02be2abd3..9422b5282 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -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: 17.1.1 +version: 17.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