Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
67143d9
Example app runs on web
Levi-Lesches Nov 15, 2024
6cf51e6
Example app recognizes Web plugin
Levi-Lesches Nov 15, 2024
2e662c3
Tentative implementation of show()
Levi-Lesches Nov 15, 2024
a7458de
Added service worker to web example
Levi-Lesches Nov 15, 2024
7aff70d
Address lints
Levi-Lesches Nov 15, 2024
5599512
Use conditional imports to not break non-web platforms
Levi-Lesches Nov 15, 2024
dc0b644
Address lints
Levi-Lesches Nov 15, 2024
29acdf2
More formatting
Levi-Lesches Nov 15, 2024
2d7d158
Used dart format
Levi-Lesches Nov 15, 2024
dfde334
Implemented cancel() and cancelAll()
Levi-Lesches Nov 15, 2024
086041b
Dart format
Levi-Lesches Nov 15, 2024
76656e1
Added WebNotificationDetails
Levi-Lesches Nov 17, 2024
40729d9
Formatted
Levi-Lesches Nov 17, 2024
d117eb2
Added WebNotificationAction
Levi-Lesches Nov 17, 2024
fad5693
Added text action and removed web examples that don't fit
Levi-Lesches Nov 17, 2024
eeabab0
Implemented pending and periodically to no-op or throw
Levi-Lesches Nov 17, 2024
da66c20
Merge remote-tracking branch 'origin/master' into web
Levi-Lesches Sep 16, 2025
87b91e5
Web Package
Levi-Lesches Sep 16, 2025
f48aa5b
Added foreground callbacks
Levi-Lesches Sep 16, 2025
24fedf9
Launch handler
Levi-Lesches Sep 16, 2025
3ceea7e
Formatted
Levi-Lesches Sep 16, 2025
2f6eda0
Documented actions
Levi-Lesches Sep 16, 2025
85c0667
Documented direction
Levi-Lesches Sep 16, 2025
d23c04f
Documented utils
Levi-Lesches Sep 16, 2025
9ff8351
Documented handler
Levi-Lesches Sep 16, 2025
12fcf51
Documented details
Levi-Lesches Sep 16, 2025
0ce22e9
Added web-specific examples
Levi-Lesches Sep 17, 2025
5f6819f
Formatted
Levi-Lesches Sep 17, 2025
2939520
More documentation
Levi-Lesches Sep 17, 2025
88b2226
Changelog and License
Levi-Lesches Sep 17, 2025
95178a5
Fix notification handler on non-chrome
Levi-Lesches Sep 17, 2025
1bdb58e
Bumped melos-config SDK versions
Levi-Lesches Sep 17, 2025
d7450ee
Fix CI
Levi-Lesches Sep 17, 2025
a7612c3
Fix pubspecs
Levi-Lesches Sep 17, 2025
c262a1b
Typo
Levi-Lesches Sep 17, 2025
752d8e5
Web stub for example
Levi-Lesches Sep 17, 2025
0675383
Updated example and main readme
Levi-Lesches Sep 17, 2025
ab264d4
Formatted
Levi-Lesches Sep 17, 2025
dd4f491
Added version to example
Levi-Lesches Sep 17, 2025
621a747
Updated reamde again
Levi-Lesches Sep 17, 2025
63b3296
Pubspec description
Levi-Lesches Sep 17, 2025
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
39 changes: 39 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,45 @@ jobs:
cd f\e
dart pub get
dart run msix:create
build_example_web_stable:
name: Build Web example app (stable channel)
runs-on: ubuntu-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: Build
run: |
cd flutter_local_notifications/example
dart pub get
flutter build web
build_example_web_3_22:
name: Build Web example app (3.22)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.22.0
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- name: Install Tools
run: |
dart pub global activate melos
melos bootstrap
- name: Build
run: |
cd flutter_local_notifications/example
dart pub get
flutter build web
unit_tests_dart:
name: Run all unit tests except for Windows (Dart)
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This repository consists hosts the following packages
- [`flutter_local_notifications_platform_interface`](https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_platform_interface): the code for the common platform interface
- [`flutter_local_notifications_linux`](https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_linux): the Linux implementation of [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications)
- [`flutter_local_notifications_windows`](https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_windows): the Windows implementation of [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications).
- [`flutter_local_notifications_web`](https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_web): the Web implementation of [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications).

These can be found in the corresponding directories within the same name. Most developers are likely here as they are looking to use the `flutter_local_notifications` plugin. There is a readme file within each directory with more information.

Expand Down
41 changes: 34 additions & 7 deletions flutter_local_notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ A cross platform plugin for displaying local notifications.
* **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)
* **Web** Uses the [Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)

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/4fa26a1e909a2243fa18e4d101192bb5d400fcf2/src/_data/platforms.yml)

Expand Down Expand Up @@ -165,19 +166,28 @@ The `onDidReceiveNotificationResponse` callback runs on the main isolate of the
- 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).

### Web limitations

- If you are debugging with `flutter run -d chrome`, you will see notifications but they will not respond to being clicked! This is due to the private debugging window that Flutter opens, and they will respond properly in release builds. To test notification handlers, make sure to use `flutter run -d web-server`. If you find that hot reload is broken with `-d web-server`, try to test as much as possible with `-d chrome`.
- **You must request notification permissions before showing notifications -- but only in response to a user interaction.** If you try to request permissions automatically, like on loading a page, not only may your request be automatically denied, but the browser may deem your site as abusive and no longer show any more prompts to the user, and just block everything going forward.
- Notification actions are supported by Chrome and Edge, but not Firefox or Safari. They may catch up soon, but text input fields use a standards _proposal_, not an accepted standard, and so may only work on Chrome for a while.

- Browsers don't support scheduled or repeating notifications, and browsers on Android do not support custom vibration.

### 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.

## 📷 Screenshots

| Platform | Screenshot |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Android | <img height="480" src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/android_notification.png"> |
| 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"> |
| Platform | Screenshot |
| -------- | ------------------------------------------------------------ |
| Android | <img height="480" src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/android_notification.png"> |
| 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"> |
| Windows | <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/windows_notification.png"> |
| Web | <img src="https://github.com/MaikuB/flutter_local_notifications/raw/master/images/web_notifications.png"> |


## 👏 Acknowledgements
Expand All @@ -186,7 +196,8 @@ 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
* [Levi Lesches](https://github.com/Levi-Lesches) for adding Windows and Web support
* [Kenneth](https://github.com/kennethnym) and [lightrabbit](https://github.com/lightrabbit) for their contributions to Windows support
* ...and everyone else for their contributions. They are greatly appreciated

## 🔧 Android Setup
Expand Down Expand Up @@ -473,6 +484,22 @@ By design, iOS applications *do not* display notifications while the app is in t

For iOS 10+, use the presentation options to control the behaviour for when a notification is triggered while the app is in the foreground. The default settings of the plugin will configure these such that a notification will be displayed when the app is in the foreground.

## Web Setup

No modifications to the HTML or JavaScript are necessary. But you must make sure to request permissions at runtime properly!

```dart
final plugin = FlutterLocalNotificationsPlugin();
await plugin.initialize();

if (!plugin.hasPermission) {
// IMPORTANT: Only call this after a button press!
await plugin.requestNotificationsPermission();
}
```

Everything else works like the other platforms.

## ❓ Usage

Before going on to copy-paste the code snippets in this section, double-check you have configured your application correctly.
Expand Down
5 changes: 1 addition & 4 deletions flutter_local_notifications/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
16 changes: 8 additions & 8 deletions flutter_local_notifications/example/.metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
channel: stable
revision: "603104015dd692ea3403755b55d07813d5cf8965"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: macos
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
create_revision: 603104015dd692ea3403755b55d07813d5cf8965
base_revision: 603104015dd692ea3403755b55d07813d5cf8965
- platform: web
create_revision: 603104015dd692ea3403755b55d07813d5cf8965
base_revision: 603104015dd692ea3403755b55d07813d5cf8965

# User provided section

Expand Down
Loading
Loading