Skip to content

Commit f015afc

Browse files
Levi-LeschesMaikuB
andauthored
[flutter_local_notifications_windows] Fix URIs on Windows -- images and audio (#2511)
* Updated _windows to use proper URIs for images and audio * Lints and format * Consolidated consdtructors * Bumped versions * Configure melos to use flutter test for Windows * Update changelog * Updated changelog again * Elaborated on changelogs * Updated docs * Converted WindowsImage back to URIs * Updated examples and tests * Moved docs * Updated changelogs * Formatted * temporarily enable verbose logging * Updated to use new package:msix functions * Use Msix.hasPackageIdentity for WindowsNotificationAudio.asset * Implemented hasPackageIdentity() and assetUri() * Formatted * Updated changelogs * Disabled avoid_classes_with_only_static_members * Bumped minimum dart: ^3.4, flutter: ^3.22 * Bumped to dart: 3.5, flutter: 3.24 * Moved FFI code around to not need package:win32 * Revert "Bumped to dart: 3.5, flutter: 3.24" This reverts commit b966b1d. * Revert "Bumped minimum dart: ^3.4, flutter: ^3.22" This reverts commit 35a1324. * Made WindowsPlugin.isValidXml * Stabilized flaky tests * Updated melos and changelogs * Cancel notif after schedule test * Skip flaky test * Added Windows XML validation to the example * Deleted problematic tests * Update melos.yaml * Addressed feedback * Removed enableMultithreading() * remove more enableMultithreading --------- Co-authored-by: Michael Bui <[email protected]>
1 parent 2f5215d commit f015afc

32 files changed

+446
-374
lines changed

analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ linter:
1010
- avoid_bool_literals_in_conditional_expressions
1111
- avoid_catches_without_on_clauses
1212
- avoid_catching_errors
13-
- avoid_classes_with_only_static_members
1413
- avoid_double_and_int_checks
1514
- avoid_empty_else
1615
- avoid_equals_and_hash_code_on_mutable_classes

flutter_local_notifications/CHANGELOG.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [19.0.0-dev.4]
2+
3+
* [Windows] **Breaking change** Reworked the APIs around custom images and audio. Check the updated example for more details, but in short:
4+
* Instead of `WindowsNotificationAudio.fromFile()`, use `WindowsNotificationAudio.asset()`
5+
* Instead of `WindowsImage.file()`, use `WindowsImage()`. See the docs for what URIs are supported
6+
* [Windows] Added `MsixUtils.hasPackageIdentity()` and `MsixUtils.assetUri()`. You shouldn't need to use `.assetUri()` directly, but it may be helpful to check `.hasPackageIdentity()` to know what features your application can support.
7+
* [Windows] Added `FlutterLocalNotificationsWindows.isValidXml()` for testing raw XML.
8+
19
## [19.0.0-dev.3]
210

311
* [iOS][macOS] **Breaking changes** the `DarwinNotificationActionOption` and `DarwinNotificationCategoryOption` are now enhanced enums with values accessible through the `value` property that are exactly the same as their native representations. Previously a bitwise left shift operation was applied to the index value
@@ -13,7 +21,7 @@
1321

1422
* **Breaking change** bumped minimum Flutter SDK requirement to 3.19.0 and Dart SDK requirement to 3.3.0
1523
* **Breaking change** [iOS] removed `uiLocalNotificationDateInterpretation` parameter from `zonedSchedule()` method. This was done as it actually no relevant as of the 18.0.0 that dropped support for iOS versions older than 10, which in turn meant that the deprecated `UILocalNotification` APIs from Apple were no longer used. The corresponding `UILocalNotificationDateInterpretation` enum has already been removed as well
16-
* [Windows] Added support for Windows. Thanks to the PR from [Levi Lesches](https://github.com/Levi-Lesches/) that continued from the contributions from
24+
* [Windows] Added support for Windows. Thanks to the PR from [Levi Lesches](https://github.com/Levi-Lesches/) that continued from the contributions from
1725
* Bumped `timezone` dependency so that minimum version is now 0.10.0
1826

1927
## [18.0.1]
@@ -167,7 +175,7 @@
167175
# [15.1.0]
168176

169177
* [iOS][macOS] added the ability to request provisional permissions. On iOS, this is only applicable to iOS 12 or newer. On macOS, this property is only applicable to macOS 10.14 or newer. Thanks to the PR from [Tokenyet](https://github.com/MaikuB/flutter_local_notifications/pull/2022)
170-
178+
171179
# [15.0.1]
172180

173181
* [Android] fixed issue [2033](https://github.com/MaikuB/flutter_local_notifications/issues/2033) where notifications on scheduled using older version of the plugin 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 part of the 14.1.2 hotfix release
@@ -176,7 +184,7 @@
176184

177185
* **Breaking change** removed deprecated `schedule()`, `showDailyAtTime()` and `showWeeklyAtDayAndTime()` methods. Notifications that were scheduled prior to this release should still work
178186
* **Breaking change** removed `Time` class
179-
* [Linux] **Breaking change** calling `zonedSchedule()` on Linux will now throw an `UnimplementedError` to align with how their is a Linux implementation but the method hasn't been implemented
187+
* [Linux] **Breaking change** calling `zonedSchedule()` on Linux will now throw an `UnimplementedError` to align with how their is a Linux implementation but the method hasn't been implemented
180188
* [iOS][macOS] **Breaking change** added supported for banner and list presentation options for iOS and macOS that is applicable for iOS 14.0 or newer and macOS 11 or newer. This is a breaking change as the values default to true and the alert presentation option is no longer applicable on these OS versions as Apple has deprecated it to be replaced by the banner and list presentations. Please ensure that if you target these OS versions that you configure the options appropriately for your application.
181189
* [Android] updated tags used when writing error logs. For corrupt scheduled notifications and error is logged the tag is now `ScheduledNotifReceiver` instead of `ScheduledNotifReceiver`. When logging that exact alarm permissions have been revoked the the tag is now `FLTLocalNotifPlugin` instead of `notification`
182190
* Updated API documentation related to the iOS/macOS notification presentation options to include links to Apple's documentations to show what they correspond to
@@ -272,10 +280,10 @@
272280
...
273281
}
274282
```
275-
283+
276284
# [12.0.4]
277285

278-
* Fixed issue [1796](https://github.com/MaikuB/flutter_local_notifications/issues/1796) where a `java.lang.ClassCastException` may be thrown on some Android devices when the `onDidReceiveBackgroundNotificationResponse` has been specified when calling `initialize()`
286+
* Fixed issue [1796](https://github.com/MaikuB/flutter_local_notifications/issues/1796) where a `java.lang.ClassCastException` may be thrown on some Android devices when the `onDidReceiveBackgroundNotificationResponse` has been specified when calling `initialize()`
279287

280288
# [12.0.3+1]
281289

@@ -299,7 +307,7 @@
299307

300308
# [12.0.1]
301309

302-
* [Android][iOS] fixed issue [1721](https://github.com/MaikuB/flutter_local_notifications/issues/1721) where a crash occurs upon tapping on a notification action fbut the `onDidReceiveBackgroundNotificationResponse` optional callback hasn't been specified.
310+
* [Android][iOS] fixed issue [1721](https://github.com/MaikuB/flutter_local_notifications/issues/1721) where a crash occurs upon tapping on a notification action fbut the `onDidReceiveBackgroundNotificationResponse` optional callback hasn't been specified.
303311
* [iOS] suppressed deprecation warnings where plugin was Apple's old notification APIs to support older iOS devices
304312

305313
# [12.0.0]
@@ -333,7 +341,7 @@
333341
* `GET_ACTIVE_NOTIFICATION_MESSAGING_STYLE_ERROR_CODE` -> `getActiveNotificationMessagingStyle`
334342
* `PERMISSION_REQUEST_IN_PROGRESS` -> `permissionRequestInProgress`
335343
* [Android] **Breaking change** the `category` of the `AndroidNotificationDetails` now requires an instance of the newly added `AndroidNotificationCategory` class instead of a string. This was to improve the discoverability of the APIs and improve the semantics as the category can specified in a similar fashion to using an enum value
336-
* **Breaking change** callbacks have now been reworked. There are now the following callbacks and both will pass an instance of the `NotificationResponse` class
344+
* **Breaking change** callbacks have now been reworked. There are now the following callbacks and both will pass an instance of the `NotificationResponse` class
337345
* `onDidReceiveNotificationResponse`: invoked only when the app is running. This works for when a user has selected a notification or notification action. This replaces the `onSelectNotification` callback that existed before. For notification actions, the action needs to be configured to indicate the the app or user interface should be shown on invoking the action for this callback to be invoked i.e. by specifying the `DarwinNotificationActionOption.foreground` option on iOS and the `showsUserInterface` property on Android. On macOS and Linux, as there's no support for background isolates it will always invoke this callback
338346
* `onDidReceiveBackgroundNotificationResponse`: invoked on a background isolate for when a user has selected a notification action. This replaces the `onSelectNotificationAction` callback
339347
* **Breaking change** the `NotificationAppLaunchDetails` has been updated to contain an instance `NotificationResponse` class with the `payload` belonging to the `NotificationResponse` class. This is to allow knowing more details about what caused the app to launch e.g. if a notification action was used to do so
@@ -435,7 +443,7 @@
435443
# [9.2.0]
436444

437445
* [Android] Added `areNotificationsEnabled()` method to `AndroidFlutterLocalNotificationsPlugin`. This allows querying if notifications are enabled for the app calling the method. Thanks to the PR from [Konstantin Pelz](https://github.com/komape)
438-
* [Linux] Fix `initialize()` returning null all the time instead of returning an appropriate boolean value to indicate if plugin has been initialised
446+
* [Linux] Fix `initialize()` returning null all the time instead of returning an appropriate boolean value to indicate if plugin has been initialised
439447

440448
# [9.1.5]
441449

@@ -836,7 +844,7 @@ Please note that there are a number of breaking changes in this release to impro
836844
* `BitmapSource.Drawable` -> `DrawableResourceAndroidBitmap`
837845
* `BitmapSource.FilePath` -> `FilePathAndroidBitmap`
838846
839-
Each of these subclasses has a constructor that an argument referring to the bitmap itself. For example, if you previously had the following code
847+
Each of these subclasses has a constructor that an argument referring to the bitmap itself. For example, if you previously had the following code
840848
841849
```dart
842850
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
@@ -888,7 +896,7 @@ Please note that there are a number of breaking changes in this release to impro
888896
* The `DefaultStyleInformation` class now implements the `StyleInformation` class instead of extending it
889897
* Where possible, classes in the plugins have been updated to provide `const` constructors
890898
* Updates to API docs and readme
891-
* Bump Android dependencies
899+
* Bump Android dependencies
892900
* Fixed a grammar issue 0.9.1 changelog entry
893901

894902
# [1.3.0]
@@ -1164,7 +1172,7 @@ Please note that there are a number of breaking changes in this release to impro
11641172

11651173
# [0.4.2]
11661174

1167-
* **Breaking change** Fix issue [127](https://github.com/MaikuB/flutter_local_notifications/issues/127) by changing plugin to Android Support Library version 27.1.1, compile and target SDK version to 27 due to issues Flutter has with API 28.
1175+
* **Breaking change** Fix issue [127](https://github.com/MaikuB/flutter_local_notifications/issues/127) by changing plugin to Android Support Library version 27.1.1, compile and target SDK version to 27 due to issues Flutter has with API 28.
11681176

11691177
# [0.4.1+1]
11701178
* Remove unused code in example app
@@ -1174,7 +1182,7 @@ Please note that there are a number of breaking changes in this release to impro
11741182
* **Breaking change** renamed the `selectNotification` callback exposed by the `initialize` function to `onSelectNotification`
11751183
* **Breaking change** renamed the `MessageHandler` typedef to `SelectNotificationCallback`
11761184
* **Breaking change** updated plugin to Android Support Library version 28.0, compile and target SDK version to 28
1177-
* Address issue [115](https://github.com/MaikuB/flutter_local_notifications/issues/115) by adding validation to the notification ID values. This ensure they're within the range of a 32-bit integer as notification IDs on Android need to be within that range. Note that an `ArgumentError` is thrown when a value is out of range.
1185+
* Address issue [115](https://github.com/MaikuB/flutter_local_notifications/issues/115) by adding validation to the notification ID values. This ensure they're within the range of a 32-bit integer as notification IDs on Android need to be within that range. Note that an `ArgumentError` is thrown when a value is out of range.
11781186
* Updated the Android Integration section around registering receivers via the Android manifest as per the suggestion in [116](https://github.com/MaikuB/flutter_local_notifications/issues/116)
11791187
* Updated version of the http dependency for used by the example app
11801188

flutter_local_notifications/example/lib/main.dart

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ class _HomePageState extends State<HomePage> {
218218
final TextEditingController _linuxIconPathController =
219219
TextEditingController();
220220

221-
final TextEditingController _windowsRawXmlController =
222-
TextEditingController();
223-
224221
bool _notificationsEnabled = false;
225222

226223
@override
@@ -966,11 +963,7 @@ class _HomePageState extends State<HomePage> {
966963
},
967964
),
968965
],
969-
if (!kIsWeb && Platform.isWindows)
970-
...windows.examples(
971-
xmlController: _windowsRawXmlController,
972-
showXmlNotification: _showWindowsNotificationWithRawXml,
973-
),
966+
if (!kIsWeb && Platform.isWindows) ...windows.examples(),
974967
],
975968
),
976969
),
@@ -1061,7 +1054,7 @@ class _HomePageState extends State<HomePage> {
10611054
WindowsAction(
10621055
content: 'Image',
10631056
arguments: 'image',
1064-
image: File('icons/coworker.png').absolute,
1057+
imageUri: WindowsImage.getAssetUri('icons/coworker.png'),
10651058
),
10661059
const WindowsAction(
10671060
content: 'Context',
@@ -1331,8 +1324,10 @@ class _HomePageState extends State<HomePage> {
13311324
);
13321325
final WindowsNotificationDetails windowsNotificationDetails =
13331326
WindowsNotificationDetails(
1334-
audio: WindowsNotificationAudio.preset(
1335-
sound: WindowsNotificationSound.alarm5),
1327+
audio: WindowsNotificationAudio.asset(
1328+
'sound/slow_spring_board.mp3',
1329+
fallback: WindowsNotificationSound.alarm5,
1330+
),
13361331
);
13371332
final NotificationDetails notificationDetails = NotificationDetails(
13381333
android: androidNotificationDetails,
@@ -2700,16 +2695,6 @@ class _HomePageState extends State<HomePage> {
27002695
platformChannelSpecifics,
27012696
);
27022697
}
2703-
2704-
Future<void>? _showWindowsNotificationWithRawXml() =>
2705-
flutterLocalNotificationsPlugin
2706-
.resolvePlatformSpecificImplementation<
2707-
FlutterLocalNotificationsWindows>()
2708-
?.showRawXml(
2709-
id: id++,
2710-
xml: _windowsRawXmlController.text,
2711-
bindings: <String, String>{'message': 'Hello, World!'},
2712-
);
27132698
}
27142699

27152700
Future<void> _showLinuxNotificationWithBodyMarkup() async {

0 commit comments

Comments
 (0)