Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_local_notifications_windows] Windows FFI plugin #2366

Open
wants to merge 110 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
278f9b3
Start impl of Windows notifications
kennethnym Feb 9, 2022
ac1cd51
Remove dependency override
kennethnym Feb 9, 2022
962ca96
Merge branch 'master' into windows-impl
kennethnym Feb 9, 2022
e0370c0
Fix notification content not showing
kennethnym Feb 10, 2022
7b5dfa3
Implement initialize method
kennethnym Feb 10, 2022
1fd635e
WIP impl of cancelling notifications
kennethnym Feb 10, 2022
1fad545
Add support for optional title/body
kennethnym Feb 11, 2022
8c53f57
Impl Registry logic for notification handling
kennethnym Feb 13, 2022
b8beedd
Tidy up code
kennethnym Feb 13, 2022
34e187c
Remove dependency overrides
kennethnym Feb 14, 2022
5400c0b
Implement cancel/cancelAll
kennethnym Feb 14, 2022
0c21c9d
WIP: Impl onSelectNotification
kennethnym Mar 5, 2022
d2f66e9
Fix read access violation
kennethnym Mar 5, 2022
dd813e1
Small fix on notification.
azchohfi Mar 28, 2022
57ecbf0
Pass payload to Dart on notification selected
kennethnym Mar 31, 2022
0baa7db
Remove melos files
kennethnym Mar 31, 2022
5ad6464
Attempting to handle msix
kennethnym Apr 13, 2022
effca5a
Forgot to check for optional value
kennethnym Apr 13, 2022
31b1ee7
Fix Initialize not returning value
kennethnym Apr 19, 2022
adf9574
temp fix issue about GetCurrentPackageFullName
lightrabbit Sep 18, 2022
3fdf27c
Merge branch 'master' into windows-impl
lightrabbit Sep 26, 2022
0d5035c
fix: windows impl with upstream merge
lightrabbit Sep 26, 2022
168f9ba
feat: support specify guid in windows
lightrabbit Sep 26, 2022
d2da530
fix: ERROR_INVALID_PARAMETER when GetCurrentPackageFullName.
lightrabbit Sep 27, 2022
58d987d
feat: support raw xml in windows
lightrabbit Sep 27, 2022
aa90cdc
Merge tag 'flutter_local_notifications-v11.0.1' into windows-impl
lightrabbit Sep 27, 2022
4b0a12a
Merged master into windows-impl
LeviLesches-KDAB Jun 25, 2024
5852669
Init error
LeviLesches-KDAB Jun 25, 2024
254b941
Merged lightrabbit's code
LeviLesches-KDAB Jun 25, 2024
b7be7e9
Catch issues with GUIDs
LeviLesches-KDAB Jun 25, 2024
610b010
Support all of the Windows Toast Notification API
LeviLesches-KDAB Jun 26, 2024
6fda1b4
Send user input back to plugin
LeviLesches-KDAB Jun 26, 2024
8692daa
Fixed typos
LeviLesches-KDAB Jun 26, 2024
4e043fc
Added getActiveNotifications for Windows
LeviLesches-KDAB Jun 26, 2024
8674b68
All examples working!
LeviLesches-KDAB Jun 27, 2024
be5584c
Added update, not working on unpackaged
LeviLesches-KDAB Jun 27, 2024
6ac515f
Copied NotificationManager
LeviLesches-KDAB Jun 27, 2024
014c3b7
Hiding old code for now
LeviLesches-KDAB Jun 27, 2024
3568ad0
one more try at progress
LeviLesches-KDAB Jun 27, 2024
5089d4b
Experimental update support
LeviLesches-KDAB Jun 27, 2024
f5f4688
V2
LeviLesches-KDAB Jun 27, 2024
fbe9c03
Working progress updates
LeviLesches-KDAB Jun 28, 2024
30e8131
Formatting
LeviLesches-KDAB Jun 28, 2024
bfab5f7
All notifications working
LeviLesches-KDAB Jun 28, 2024
d4ac6d2
Moved Windows examples out of main.dart;
LeviLesches-KDAB Jun 28, 2024
7301018
cleanup
LeviLesches-KDAB Jun 28, 2024
0c0ff81
Hide repeating examples on Windows
LeviLesches-KDAB Jul 1, 2024
da9a6fc
Merge branch 'master' into windows-impl
LeviLesches-KDAB Jul 1, 2024
7f3ccca
Moved example XML box to bottom
LeviLesches-KDAB Jul 1, 2024
3a0699b
Made WindowsImage.file constructor
LeviLesches-KDAB Jul 1, 2024
4abc927
getLaunchDetails working
LeviLesches-KDAB Jul 1, 2024
56f152a
Cleanup
LeviLesches-KDAB Jul 1, 2024
66574c0
Made all images msix safe
LeviLesches-KDAB Jul 2, 2024
29309a9
Catch when getLaunchDetails() is called before init() and add dynamic…
LeviLesches-KDAB Jul 2, 2024
370c19e
Fixed issue with special characters in file
LeviLesches-KDAB Jul 7, 2024
dd335e6
Added Windows FFI package
LeviLesches-KDAB Jul 10, 2024
36c170e
moved to FFI plugin
LeviLesches-KDAB Jul 11, 2024
d004ad3
Reduced C <--> C++ logic, embraced C API
LeviLesches-KDAB Jul 11, 2024
1cdc0c4
Upgraded Dart to 3.1.0
LeviLesches-KDAB Jul 11, 2024
a5cc1b0
Documented the C++ code
LeviLesches-KDAB Jul 12, 2024
37ad031
Made more constructors const
LeviLesches-KDAB Jul 12, 2024
b8c3e27
Updated example
LeviLesches-KDAB Jul 12, 2024
cb08f6f
Documented Dart APIs
LeviLesches-KDAB Jul 12, 2024
a9b1892
Added unit tests and polished
LeviLesches-KDAB Jul 16, 2024
56f037e
Configured exampleand Melos for Windows
LeviLesches-KDAB Jul 16, 2024
3a99aa3
Merge branch 'master' into windows-ffi
LeviLesches-KDAB Jul 16, 2024
6470448
Documented everything and removed Flutter dependency from _windows
LeviLesches-KDAB Jul 17, 2024
fa8c2c5
Added retry to flaky test
LeviLesches-KDAB Jul 17, 2024
5b37ea7
Documented the crash test
LeviLesches-KDAB Jul 17, 2024
af82c0c
Removed flutter from _platform_interface and bumped
LeviLesches-KDAB Jul 17, 2024
68c03ad
Removed XML from main plugin
LeviLesches-KDAB Jul 17, 2024
ed7fead
Simplify C++ code and use ffigen 13.0 for Dart enums
Levi-Lesches Aug 8, 2024
94b0f58
Made attributes and notifToXml() private
Levi-Lesches Aug 8, 2024
0584856
Fixed readme
Levi-Lesches Aug 8, 2024
aa7f45f
Fixed typo
Levi-Lesches Aug 19, 2024
801cdb0
WindowsTextInput.hintText -> .placeHolderContent;
Levi-Lesches Aug 19, 2024
bfb2350
Improved docs on WindowsNotificationText.placement
Levi-Lesches Aug 19, 2024
f100f53
Removed WindowsActivationType.background as it's only supported on UWP
Levi-Lesches Aug 19, 2024
b3bb2b9
Merged master into windows-ffi
Levi-Lesches Aug 19, 2024
be53677
Fixed warning about mixing struct and class
Levi-Lesches Aug 19, 2024
0febd6a
Changed docs for ffi plugin
Levi-Lesches Aug 19, 2024
2d5a915
Added zonedScheduleRawXml
Levi-Lesches Aug 19, 2024
d79c4dc
Doc comment tweak
Levi-Lesches Aug 19, 2024
18c73ec
Tweaked another doc comment
Levi-Lesches Aug 19, 2024
9146d65
Removed custom lints, using 80 chars per line and standard lints
Levi-Lesches Aug 20, 2024
e0be52c
Changed all C int-bools to plain bools
Levi-Lesches Aug 20, 2024
5855612
Changed C++ side to use bools as well
Levi-Lesches Aug 20, 2024
12b6705
Experimental multithreading support
Levi-Lesches Aug 20, 2024
1836051
Responded to feedback
Levi-Lesches Aug 25, 2024
53a52c1
Updated minimum Flutter version to 3.16
Levi-Lesches Aug 26, 2024
ce437e5
Added _windows to dependabot
Levi-Lesches Aug 26, 2024
223d311
Changed main package to use Dart 3.2, Flutter 3.16
Levi-Lesches Aug 26, 2024
a93fc0e
Moved all XML code to private files
Levi-Lesches Aug 26, 2024
ec69b53
Cleanup
Levi-Lesches Aug 26, 2024
cb993ca
Sealed WindowsNotificationPart
Levi-Lesches Aug 26, 2024
aad7293
Restrict tests to Windows platforms
Levi-Lesches Aug 26, 2024
8411647
Update CI to use windows-latest for Windows tests + build
Levi-Lesches Sep 4, 2024
aa44049
Formatted repo
Levi-Lesches Sep 4, 2024
f411b17
Formatted again
Levi-Lesches Sep 4, 2024
4f6e9d9
Fix Windows CI to not use .sh script
Levi-Lesches Sep 4, 2024
32c007d
Fix workflow name
Levi-Lesches Sep 4, 2024
bf5c9cc
Downgraded _windows meta to 1.11
Levi-Lesches Sep 5, 2024
b1853f1
Added parseGuid function for SDKs that don't have it built-in
Levi-Lesches Oct 15, 2024
655c49e
Merge branch 'master' into windows-ffi
Levi-Lesches Nov 1, 2024
020b1de
Use a vector instead of malloc for plugin.cpp
Levi-Lesches Nov 1, 2024
8a87d17
Updated pubspec to include Flutter and updated platform_interface
Levi-Lesches Nov 1, 2024
6336bb4
Test renaming repo
Levi-Lesches Nov 3, 2024
b2bfed3
Shorter names
Levi-Lesches Nov 3, 2024
4fe2c7f
Shorter names on Windows build version and stable
Levi-Lesches Nov 3, 2024
285de6c
Merge branch 'master' into windows-ffi
Levi-Lesches Nov 3, 2024
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ updates:
directory: "/flutter_local_notifications_linux"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/flutter_local_notifications_windows"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/flutter_local_notifications"
schedule:
Expand Down
94 changes: 79 additions & 15 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ jobs:
run: ./.github/workflows/scripts/install-tools.sh
- name: Build
run: melos run build:example_android
build_example_android_3_13:
name: Build Android example app (3.13)
build_example_android_3_19:
name: Build Android example app (3.19)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.13.0
flutter-version: 3.19.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -90,15 +90,15 @@ jobs:
run: ./.github/workflows/scripts/install-tools.sh
- name: Build
run: melos run build:example_ios
build_example_ios_3_13:
name: Build iOS example app (3.13)
build_example_ios_3_19:
name: Build iOS example app (3.19)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.13.0
flutter-version: 3.19.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -119,15 +119,15 @@ jobs:
run: ./.github/workflows/scripts/install-tools.sh
- name: Build
run: melos run build:example_macos
build_example_macos_3_13:
name: Build macOS example app (3.13)
build_example_macos_3_19:
name: Build macOS example app (3.19)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.13.0
flutter-version: 3.19.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -152,15 +152,15 @@ jobs:
- run: flutter config --enable-linux-desktop
- name: Build
run: melos run build:example_linux
build_example_linux_3_13:
name: Build Linux example app (3.13)
build_example_linux_3_19:
name: Build Linux example app (3.19)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.13.0
flutter-version: 3.19.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
Expand All @@ -171,6 +171,57 @@ jobs:
- run: flutter config --enable-linux-desktop
- name: Build
run: melos run build:example_linux
build_example_windows_stable:
name: Build Windows example app (stable channel)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
run: |
dart pub global activate melos
melos bootstrap
# Windows has a filename length limit, which this repo just hits
# This saves us precious characters during the compilation
- name: Rename directory
run: |
move flutter_local_notifications f
move f\example f\e
- name: Build
run: |
cd f\e
dart pub get
dart run msix:create
build_example_windows_3_19:
name: Build Windows example app (3.19)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.19.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
run: |
dart pub global activate melos
melos bootstrap
# Windows has a filename length limit, which this repo just hits
# This saves us precious characters during the compilation
- name: Rename directory
run: |
move flutter_local_notifications f
move f\example f\e
- name: Build
run: |
cd f\e
dart pub get
dart run msix:create
unit_tests_dart:
name: Run all unit tests (Dart)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -199,6 +250,22 @@ jobs:
run: ./.github/workflows/scripts/install-tools.sh
- name: Run Tests
run: melos run test:unit:android
unit_tests_windows:
name: Run all unit tests (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install tools
run: |
dart pub global activate melos
melos bootstrap
- name: Run Tests
run: melos run test:unit:windows
integration_tests_android:
name: Run integration tests (Android)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -245,6 +312,3 @@ jobs:
brew install applesimutils
applesimutils --byId ${{ steps.simulator-action.outputs.udid}} --bundle com.dexterous.flutterLocalNotificationsExample --setPermissions notifications=YES
- run: melos run test:integration



42 changes: 33 additions & 9 deletions flutter_local_notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

A cross platform plugin for displaying local notifications.

>[!IMPORTANT]
>[!IMPORTANT]
> Given how both quickly both Flutter ecosystem and Android ecosystem evolves, the minimum Flutter SDK version will be bumped to make it easier to maintain the plugin. Note that official plugins already follow a similar approach e.g. have a minimum Flutter SDK version of 3.13. This is being called out as if this affects your applications (e.g. supported OS versions) then you may need to consider maintaining your own fork in the future
>[!IMPORTANT]
> Given how both quickly both Flutter ecosystem and Android ecosystem evolves, the minimum Flutter SDK version will occasionally be bumped to make it easier to maintain the plugin. Note that official plugins already follow a similar approach. This is being called out as if this affects your applications (e.g. supported OS versions) then you may need to consider maintaining your own fork in the future

## Table of contents
Expand Down Expand Up @@ -59,6 +61,7 @@ A cross platform plugin for displaying local notifications.
* **iOS** Uses the [UserNotification APIs](https://developer.apple.com/documentation/usernotifications) (aka the User Notifications Framework)
* **macOS** Uses the [UserNotification APIs](https://developer.apple.com/documentation/usernotifications) (aka the User Notifications Framework)
* **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)

Expand Down Expand Up @@ -109,6 +112,10 @@ Note: the plugin requires Flutter SDK 3.13 at a minimum. The list of support pla
* [Linux] Ability to set custom hints
* [Linux] Ability to suppress sound
* [Linux] Resident and transient notifications
* [Windows] Can show raw XML (see the [Notifications Visualizer](https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/notifications-visualizer))
* [Windows] A full Dart API for all the options supported by toast notifications
* [Windows] Can configure images, buttons, dropdowns, text input, and launch behavior
* [Windows] Can dynamically update notifications after they've been shown

## ⚠ Caveats and limitations

Expand Down Expand Up @@ -154,6 +161,11 @@ Scheduled/pending notifications is currently not supported due to the lack of a

The `onDidReceiveNotificationResponse` callback runs on the main isolate of the running application and cannot be launched in the background if the application is not running. To respond to notification after the application is terminated, your application should be registered as DBus activatable (please see [DBusApplicationLaunching](https://wiki.gnome.org/HowDoI/DBusApplicationLaunching) for more information), and register action before activating the application. This is difficult to do in a plugin because plugins instantiate during application activation, so `getNotificationAppLaunchDetails` can't be implemented without changing the main user application.

### Windows limitations

- Windows does not support repeating notifications, so [`periodicallyShow`](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/periodicallyShow.html) and [`periodicallyShowWithDuration`](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/periodicallyShowWithDuration.html) will throw `UnsupportedError`s.
- Windows only allows apps with package identity to retrieve previously shown notifications. This means that on an app that was not packaged as an [MSIX](https://learn.microsoft.com/en-us/windows/msix/overview) installer, [`cancel`](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/cancel.html) does nothing and [`getActiveNotifications`](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/getActiveNotifications.html) will return an empty list. To package your app as an MSIX, see [`package:msix`](https://pub.dev/packages/msix) and the `msix` section in [the example's `pubspec.yaml`](https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/example/pubspec.yaml).

### Notification payload

Due to some limitations on iOS with how it treats null values in dictionaries, a null notification payload is coalesced to an empty string behind the scenes on all platforms for consistency.
Expand All @@ -166,6 +178,7 @@ Due to some limitations on iOS with how it treats null values in dictionaries, a
| iOS | <img height="414" src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/ios_notification.png"> |
| macOS | <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/macos_notification.png"> |
| Linux | <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/gnome_linux_notification.png"> <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/kde_linux_notification.png"> |
| Windows | <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/windows_notification.png"> |


## 👏 Acknowledgements
Expand All @@ -174,6 +187,7 @@ Due to some limitations on iOS with how it treats null values in dictionaries, a
* [Jeff Scaturro](https://github.com/JeffScaturro) for submitting the PR to fix the iOS issue around showing daily and weekly notifications and migrating the plugin to AndroidX
* [Ian Cavanaugh](https://github.com/icavanaugh95) for helping create a sample to reproduce the problem reported in [issue #88](https://github.com/MaikuB/flutter_local_notifications/issues/88)
* [Zhang Jing](https://github.com/byrdkm17) for adding 'ticker' support for Android notifications
* [Kenneth](https://github.com/kennethnym), [lightrabbit](https://github.com/lightrabbit), and [Levi Lesches](https://github.com/Levi-Lesches) for adding Windows support
* ...and everyone else for their contributions. They are greatly appreciated

## 🔧 Android Setup
Expand Down Expand Up @@ -270,7 +284,7 @@ For apps that need the following functionality please complete the following in
* Declare the service exposed by the plugin by adding the following between `<application>` tags. An example of what this looks like is below where `<foreground service types>` should be replaced with the foreground service type(s) your app needs. If you want your foreground service to be stopped if your app is stopped, set `android:stopWithTask` to `true`
```xml
<service
android:name="com.dexterous.flutterlocalnotifications.ForegroundService"
android:name="com.dexterous.flutterlocalnotifications.ForegroundService"
android:exported="false"
android:stopWithTask="false"
android:foregroundServiceType="<foreground service types>">
Expand Down Expand Up @@ -386,7 +400,7 @@ then extend `didFinishLaunchingWithOptions` and register the callback:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];

// Add this method
// Add this method
[FlutterLocalNotificationsPlugin setPluginRegistrantCallback:registerPlugins];
}
```
Expand Down Expand Up @@ -529,11 +543,18 @@ final DarwinInitializationSettings initializationSettingsDarwin =
final LinuxInitializationSettings initializationSettingsLinux =
LinuxInitializationSettings(
defaultActionName: 'Open notification');
final WindowsInitializationSettings initializationSettingsWindows =
WindowsInitializationSettings(
appName: 'Flutter Local Notifications Example',
appUserModelId: 'Com.Dexterous.FlutterLocalNotificationsExample',
// Search online for GUID generators to make your own
guid: 'd49b0314-ee7a-4626-bf79-97cdb8a991bb')
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
macOS: initializationSettingsDarwin,
linux: initializationSettingsLinux);
linux: initializationSettingsLinux,
windows: initializationSettingsWindows);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse);
```
Expand All @@ -557,9 +578,9 @@ void onDidReceiveNotificationResponse(NotificationResponse notificationResponse)

In the real world, this payload could represent the id of the item you want to display the details of. Once the initialisation is complete, then you can manage the displaying of notifications. Note that this callback is only intended to work when the app is running. For scenarios where your application needs to handle when a notification launched the app refer to [here](#getting-details-on-if-the-app-was-launched-via-a-notification-created-by-this-plugin)

The `DarwinInitializationSettings` class provides default settings on how the notification be presented when it is triggered and the application is in the foreground on iOS/macOS. There are optional named parameters that can be modified to suit your application's purposes. Here, it is omitted and the default values for these named properties is set such that all presentation options (alert, sound, badge) are enabled.
The `DarwinInitializationSettings` class provides default settings on how the notification be presented when it is triggered and the application is in the foreground on iOS/macOS. There are optional named parameters that can be modified to suit your application's purposes. Here, it is omitted and the default values for these named properties is set such that all presentation options (alert, sound, badge) are enabled.

The `LinuxInitializationSettings` class requires a name for the default action that calls the `onDidReceiveNotificationResponse` callback when the notification is clicked.
The `LinuxInitializationSettings` class requires a name for the default action that calls the `onDidReceiveNotificationResponse` callback when the notification is clicked.

On iOS and macOS, initialisation may show a prompt to requires users to give the application permission to display notifications (note: permissions don't need to be requested on Android). Depending on when this happens, this may not be the ideal user experience for your application. If so, please refer to the next section on how to work around this.

Expand Down Expand Up @@ -647,7 +668,7 @@ The details specific to the Android platform are also specified. This includes t

### Scheduling a notification

Starting in version 2.0 of the plugin, scheduling notifications now requires developers to specify a date and time relative to a specific time zone. This is to solve issues with daylight saving time that existed in the `schedule` method that is now deprecated. A new `zonedSchedule` method is provided that expects an instance `TZDateTime` class provided by the [`timezone`](https://pub.dev/packages/timezone) package. Even though the `timezone` package is be a transitive dependency via this plugin, it is recommended based on [this lint rule](https://dart-lang.github.io/linter/lints/depend_on_referenced_packages.html) that you also add the `timezone` package as a direct dependency.
Starting in version 2.0 of the plugin, scheduling notifications now requires developers to specify a date and time relative to a specific time zone. This is to solve issues with daylight saving time that existed in the `schedule` method that is now deprecated. A new `zonedSchedule` method is provided that expects an instance `TZDateTime` class provided by the [`timezone`](https://pub.dev/packages/timezone) package. Even though the `timezone` package is be a transitive dependency via this plugin, it is recommended based on [this lint rule](https://dart-lang.github.io/linter/lints/depend_on_referenced_packages.html) that you also add the `timezone` package as a direct dependency.

Once the depdendency as been added, usage of the `timezone` package requires initialisation that is covered in the package's readme. For convenience the following are code snippets used by the example app.

Expand Down Expand Up @@ -699,6 +720,8 @@ If you are trying to update your code so it doesn't use the deprecated methods f

### Periodically show a notification with a specified interval

**Note** This is not supported on Windows

```dart
const AndroidNotificationDetails androidNotificationDetails =
AndroidNotificationDetails(
Expand All @@ -720,8 +743,7 @@ final List<PendingNotificationRequest> pendingNotificationRequests =

### Retrieving active notifications



**Note** On Windows, your app must be packaged as an MSIX to do this. See the limitations section.

```dart
final List<ActiveNotification> activeNotifications =
Expand Down Expand Up @@ -805,6 +827,8 @@ await flutterLocalNotificationsPlugin.show(

### Cancelling/deleting a notification

**Note** On Windows, your app must be packaged as an MSIX to do this. See the limitations section.

```dart
// cancel the notification with id value of zero
await flutterLocalNotificationsPlugin.cancel(0);
Expand Down
Loading
Loading