Skip to content

Commit f59f7eb

Browse files
authored
[flutter_local_notifications] updated presentSound and defaultPresentSound API docs around background app behaviour (#2112)
* added more details on background sound behaviour to presentSound and defaultPresentSound * added changelog entry
1 parent eeaf120 commit f59f7eb

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

Diff for: flutter_local_notifications/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* [Android] bumped Java desugaring dependency and updated readme accordingly to also mention Gradle version that is used by plugin
77
* [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. This was also released as part of the 15.1.1 and 14.1.3 hotfix releases
88
* [Android] fixed issue [2106](https://github.com/MaikuB/flutter_local_notifications/issues/2106) where calling `getNotificationChannels()` reports the wrong importance level or result in an exception if the importance level was unspecified. This was also released as part of the 15.1.2 and 14.1.4 hotfix releases
9+
* [iOS][macOS] addresses issue [2097](https://github.com/MaikuB/flutter_local_notifications/issues/2097) by updating API docs for the `presentSound` and `defaultPresentSound` properties that belong to the `DarwinNotificationDetails` and `DarwinInitializationSettings` classes respectively to clarify the background behaviour and how have a sound play even when app is the background yet these properties are set to false
910
* Updated example app so that the Android side specifies minimum SDK version version that aligns with what's specified by the Flutter SDK
1011
* Fixed Dart API docs for `DarwinNotificationDetails` class where `this This` was being repeated. Thanks to the PR from [Adrian Jagielak](https://github.com/adrianjagielak)
1112
* Fixed example code shown at the "Handling notifications whilst the app is in the foreground" section of the readme. Thanks to the PR from [Tinh Huynh](https://github.com/TinhHuynh)

Diff for: flutter_local_notifications/lib/src/platform_specifics/darwin/initialization_settings.dart

+10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ class DarwinInitializationSettings {
7676
///
7777
/// Default value is true.
7878
///
79+
/// If this is set to false to indicate that the notification shouldn't play
80+
/// a sound in the foreground then note that for consistency, the notification
81+
/// won't play a sound when the app is in the background. If the intention in
82+
/// this scenario is to have the app also play the default notification sound
83+
/// whilst the app is in the background as well, then the
84+
/// [DarwinNotificationDetails.sound] should be set to an arbitrary value
85+
/// (e.g. empty string) that doesn't match a custom sound file. This way the
86+
/// platform fails to find a custom sound file to fallback to the default
87+
/// notification sound.
88+
///
7989
/// On iOS, this property is only applicable to iOS 10 or newer.
8090
/// On macOS, this property is only applicable to macOS 10.14 or newer.
8191
final bool defaultPresentSound;

Diff for: flutter_local_notifications/lib/src/platform_specifics/darwin/notification_details.dart

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ class DarwinNotificationDetails {
4141
/// When this is set to `null`, it will use the default setting given
4242
/// to [DarwinInitializationSettings.defaultPresentSound].
4343
///
44+
/// If this is set to false to indicate that the notification shouldn't play
45+
/// a sound in the foreground then note that for consistency, the notification
46+
/// won't play a sound when the app is in the background. If the intention in
47+
/// this scenario is to have the app also play the default notification sound
48+
/// whilst the app is in the background as well, then the [sound] should be
49+
/// set to an arbitrary value (e.g. empty string) that doesn't match a custom
50+
/// sound file. This way the platform fails to find a custom sound file to
51+
/// fallback to the default notification sound.
52+
///
4453
/// This property is only applicable to iOS 10 or newer.
4554
final bool? presentSound;
4655

0 commit comments

Comments
 (0)