Skip to content
Closed
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
22 changes: 11 additions & 11 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Build
run: melos run build:example_android
build_example_android_3_19:
name: Build Android example app (3.19)
name: Build Android example app (3.22)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -78,7 +78,7 @@ jobs:
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -100,14 +100,14 @@ jobs:
- name: Build
run: melos run build:example_ios
build_example_ios_3_19:
name: Build iOS example app (3.19)
name: Build iOS example app (3.22)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -129,14 +129,14 @@ jobs:
- name: Build
run: melos run build:example_macos
build_example_macos_3_19:
name: Build macOS example app (3.19)
name: Build macOS example app (3.22)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -162,14 +162,14 @@ jobs:
- name: Build
run: melos run build:example_linux
build_example_linux_3_19:
name: Build Linux example app (3.19)
name: Build Linux example app (3.22)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand Down Expand Up @@ -206,14 +206,14 @@ jobs:
dart pub get
dart run msix:create
build_example_windows_3_19:
name: Build Windows example app (3.19)
name: Build Windows example app (3.22)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand Down
5 changes: 4 additions & 1 deletion flutter_local_notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [19.0.0-dev.5]
* **Breaking change** Require Dart 3.4 and Flutter 3.22

## [19.0.0-dev.4]

* [Windows] **Breaking change** Reworked the APIs around custom images and audio. Check the updated example for more details, but in short:
Expand All @@ -19,7 +22,7 @@

## [19.0.0-dev.1]

* **Breaking change** bumped minimum Flutter SDK requirement to 3.19.0 and Dart SDK requirement to 3.3.0
* **Breaking change** bumped minimum Flutter SDK requirement to 3.22.0 and Dart SDK requirement to 3.3.0
* **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
* [Windows] Added support for Windows. Thanks to the PR from [Levi Lesches](https://github.com/Levi-Lesches/) that continued from the contributions from
* Bumped `timezone` dependency so that minimum version is now 0.10.0
Expand Down
2 changes: 1 addition & 1 deletion flutter_local_notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ A cross platform plugin for displaying local notifications.
* **Linux**. Uses the [Desktop Notifications Specification](https://specifications.freedesktop.org/notification-spec/)
* **Windows** Uses the [C++/WinRT](https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/) implementation of [Toast Notifications](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/toast-notifications-overview)

Note: the plugin requires Flutter SDK 3.13 at a minimum. The list of support platforms for Flutter 3.13 itself can be found [here](https://github.com/flutter/website/blob/3d18ab48218101493af84953b71eac0cc6781fdd/src/reference/supported-platforms.md)
Note: the plugin requires Flutter SDK 3.22 at a minimum. The list of support platforms for Flutter 3.22 itself can be found [here](https://github.com/flutter/website/blob/3d18ab48218101493af84953b71eac0cc6781fdd/src/reference/supported-platforms.md)

## ✨ Features

Expand Down
6 changes: 3 additions & 3 deletions flutter_local_notifications/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 19.0.0-dev.4
version: 19.0.0-dev.5
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues

Expand Down Expand Up @@ -42,5 +42,5 @@ flutter:
default_package: flutter_local_notifications_windows

environment:
sdk: ^3.3.0
flutter: ">=3.19.0"
sdk: ^3.4.0
flutter: ">=3.22.0"
3 changes: 3 additions & 0 deletions flutter_local_notifications_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [1.0.0-dev.4]
* **Breaking change** Require Dart 3.4 and Flutter 3.22

## [1.0.0-dev.3]

* **Breaking change** Reworked the APIs around custom images and audio. Check the updated example for more details, but in short:
Expand Down
31 changes: 18 additions & 13 deletions flutter_local_notifications_windows/lib/src/ffi/bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ class NotificationsPluginBindings {
ffi.Pointer<pkg_ffi.Utf8>,
NativeNotificationCallback)>();

/// Shows the XML as a notification with the given ID. See [updateNotification] for details on
/// bindings.
/// Shows the XML as a notification with the given ID.
///
/// See [updateNotification] for details on bindings.
bool showNotification(
ffi.Pointer<NativePlugin> plugin,
int id,
Expand Down Expand Up @@ -346,7 +347,10 @@ final class NativeLaunchDetails extends ffi.Struct {

/// What part of the notification launched the app.
@ffi.UnsignedInt()
external int launchType;
external int launchTypeAsInt;

NativeLaunchType get launchType =>
NativeLaunchType.fromValue(launchTypeAsInt);

/// The payload sent to the app by the notification. Usually the action that was pressed.
external ffi.Pointer<pkg_ffi.Utf8> payload;
Expand All @@ -355,6 +359,17 @@ final class NativeLaunchDetails extends ffi.Struct {
external NativeStringMap data;
}

typedef NativeNotificationCallbackFunction = ffi.Void Function(
NativeLaunchDetails details);
typedef DartNativeNotificationCallbackFunction = void Function(
NativeLaunchDetails details);

/// A callback that is run with [NativeLaunchDetails] when a notification is pressed.
///
/// This may be called at app launch or even while the app is running.
typedef NativeNotificationCallback
= ffi.Pointer<ffi.NativeFunction<NativeNotificationCallbackFunction>>;

/// See: https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.notificationupdateresult
enum NativeUpdateResult {
success(0),
Expand All @@ -372,13 +387,3 @@ enum NativeUpdateResult {
throw ArgumentError("Unknown value for NativeUpdateResult: $value"),
};
}

/// A callback that is run with [NativeLaunchDetails] when a notification is pressed.
///
/// This may be called at app launch or even while the app is running.
typedef NativeNotificationCallback
= ffi.Pointer<ffi.NativeFunction<NativeNotificationCallbackFunction>>;
typedef NativeNotificationCallbackFunction = ffi.Void Function(
NativeLaunchDetails details);
typedef DartNativeNotificationCallbackFunction = void Function(
NativeLaunchDetails details);
33 changes: 16 additions & 17 deletions flutter_local_notifications_windows/lib/src/ffi/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@ import 'bindings.dart';
/// Helpful methods on native string maps.
extension NativeStringMapUtils on NativeStringMap {
/// Converts this map to a typical Dart map.
Map<String, String> toMap() => <String, String>{
Map<String, String> toDart() => <String, String>{
for (int index = 0; index < size; index++)
entries[index].key.toDartString():
entries[index].value.toDartString(),
};
}

/// Gets the [NotificationResponseType] from a [NativeLaunchType].
NotificationResponseType getResponseType(int launchType) {
switch (NativeLaunchType.fromValue(launchType)) {
case NativeLaunchType.notification:
return NotificationResponseType.selectedNotification;
case NativeLaunchType.action:
return NotificationResponseType.selectedNotificationAction;
}
extension NativeLaunchTypeUtils on NativeLaunchType {
/// Gets the [NotificationResponseType] from a [NativeLaunchType].
NotificationResponseType toDart() => switch (this) {
NativeLaunchType.notification =>
NotificationResponseType.selectedNotification,
NativeLaunchType.action =>
NotificationResponseType.selectedNotificationAction,
};
}

/// Gets the [NotificationUpdateResult] from a [NativeUpdateResult].
NotificationUpdateResult getUpdateResult(NativeUpdateResult result) {
switch (result) {
case NativeUpdateResult.success:
return NotificationUpdateResult.success;
case NativeUpdateResult.failed:
return NotificationUpdateResult.error;
case NativeUpdateResult.notFound:
return NotificationUpdateResult.notFound;
}
extension NativeUpdateResultUtils on NativeUpdateResult {
/// Gets the [NotificationUpdateResult] from a [NativeUpdateResult].
NotificationUpdateResult toDart() => switch (this) {
NativeUpdateResult.success => NotificationUpdateResult.success,
NativeUpdateResult.failed => NotificationUpdateResult.error,
NativeUpdateResult.notFound => NotificationUpdateResult.notFound,
};
}

/// Helpful methods on string maps.
Expand Down
29 changes: 20 additions & 9 deletions flutter_local_notifications_windows/lib/src/plugin/ffi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
NativeCallable<NativeNotificationCallbackFunction>.listener(
_globalLaunchCallback,
).nativeFunction;
final bool result =
_bindings.init(_plugin, appName, aumId, guid, iconPath, callback);
final bool result = _bindings.init(
_plugin,
appName,
aumId,
guid,
iconPath,
callback,
);
_isReady = result;
return result;
});
Expand All @@ -113,9 +119,9 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
_bindings.freeLaunchDetails(_details!);
}
_details = details;
final Map<String, String> data = details.data.toMap();
final Map<String, String> data = details.data.toDart();
final NotificationResponse response = NotificationResponse(
notificationResponseType: getResponseType(details.launchType),
notificationResponseType: details.launchType.toDart(),
payload: details.payload.toDartString(),
actionId: details.payload.toDartString(),
data: data,
Expand Down Expand Up @@ -189,11 +195,11 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
if (details == null) {
return null;
}
final Map<String, String> data = details.data.toMap();
final Map<String, String> data = details.data.toDart();
return NotificationAppLaunchDetails(
details.didLaunch,
notificationResponse: NotificationResponse(
notificationResponseType: getResponseType(details.launchType),
notificationResponseType: details.launchType.toDart(),
payload: details.payload.toDartString(),
actionId: details.payload.toDartString(),
data: data,
Expand Down Expand Up @@ -226,8 +232,13 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
}

@override
Future<void> show(int id, String? title, String? body,
{String? payload, WindowsNotificationDetails? details}) async =>
Future<void> show(
int id,
String? title,
String? body, {
String? payload,
WindowsNotificationDetails? details,
}) async =>
using((Arena arena) {
if (!_isReady) {
throw StateError(
Expand Down Expand Up @@ -364,6 +375,6 @@ class FlutterLocalNotificationsWindows extends WindowsNotificationsBase {
}
final NativeUpdateResult result = _bindings.updateNotification(
_plugin, id, bindings.toNativeMap(arena));
return getUpdateResult(result);
return result.toDart();
});
}
8 changes: 4 additions & 4 deletions flutter_local_notifications_windows/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: flutter_local_notifications_windows
description: Windows implementation of the flutter_local_notifications plugin
version: 1.0.0-dev.3
version: 1.0.0-dev.4
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_windows

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"
sdk: ^3.4.0
flutter: ">=3.22.0"

dependencies:
flutter:
Expand All @@ -17,7 +17,7 @@ dependencies:
xml: ^6.5.0

dev_dependencies:
ffigen: ^13.0.0
ffigen: ^16.0.0
test: ^1.25.2

flutter:
Expand Down
5 changes: 3 additions & 2 deletions flutter_local_notifications_windows/src/ffi_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ FFI_PLUGIN_EXPORT bool init(
NativeNotificationCallback callback
);

/// Shows the XML as a notification with the given ID. See [updateNotification] for details on
/// bindings.
/// Shows the XML as a notification with the given ID.
///
/// See [updateNotification] for details on bindings.
FFI_PLUGIN_EXPORT bool showNotification(
NativePlugin* plugin, int id, char* xml, NativeStringMap bindings
);
Expand Down
Loading