From 43f12201c686137b8a8080dc65981c199120cd5a Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Mon, 6 May 2024 23:12:05 +1000 Subject: [PATCH] coleasce null audio attributes when mapping notification channel --- flutter_local_notifications/CHANGELOG.md | 4 ++++ .../FlutterLocalNotificationsPlugin.java | 3 ++- flutter_local_notifications/pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index 41744831b..29ac5b537 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 error 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 tje [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..f5a12010d 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,8 @@ 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