Repository navigation
feat: flet-notifications extension - #6999
Open
ndonkoHenri wants to merge 133 commits into
Open
ndonkoHenri wants to merge 133 commits into
ndonkoHenri wants to merge 133 commits into
Conversation
`LocalNotifications` service wrapping flutter_local_notifications for Android, iOS, macOS, Windows, Linux and Web: show, schedule (zoned, daily, weekly, periodic), cancel, permissions and probes, Android channels and foreground service, rich styles (big text/picture/inbox/messaging), inline-reply actions and typed on_tap/on_action/on_dismissed handlers. The plugin needs scheduled-notification receivers and core-library-desugaring Gradle flags that [tool.flet.android.*] cannot declare, so the package ships an idempotent `flet-notifications-patch` console script for the built project.
Contributor
|
Sorry @ndonkoHenri, your pull request is larger than the review limit of 150,000 diff characters |
flet-notifications extension
9 tasks done
Deploying flet-website-v2 with
|
| Latest commit: |
dddc118
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dec45332.flet-website-v2.pages.dev |
| Branch Preview URL: | https://feat-flet-notifications.flet-website-v2.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6948
Builds on @Nwokike's work in #6977.
Adds
flet-notifications, a service for local notifications on Android, iOS, macOS, Windows, Linux and Web, built onflutter_local_notifications.The notifications are local: the app posts them itself, now or scheduled ahead, and the OS delivers scheduled ones even while the app isn't running. Push notifications (FCM/APNs) are out of scope.
The extension
show(),schedule()(time-zone aware throughZoneInfodatetimes, with daily/weekly matching),periodically_show(), cancelling one or all, and listing pending and shown notifications.on_tapandon_action(with reply text) are also called for the notification that launched the app, and for selections made while the app wasn't running: Android, iOS and macOS queue them natively and hand them over once the service starts, and Windows starts aflet buildapp to deliver them (see the limitations for Linux and other Windows apps).AndroidOptions(styles, progress, groups, channels, full-screen),DarwinOptions,WindowsOptions,LinuxOptionsandWebOptions, all passed together inNotificationOptions.NotificationExceptionsubclasses (unsupported platform, invalid argument, permission denied, …).flet buildapp also registers itself as the COM server Windows starts for a click made after the app exited, so cold taps, actions and replies reachon_tap/on_action. The plugin only registers its activator inside the running process.Docs:
website/docs/services/notifications/, with ten focused examples (basic, permissions, actions, scheduling, exact alarms, progress, active notifications, Android styles, channels, foreground service).Changes outside the extension
The extension needed some general
flet buildandflet packfeatures. They aren't notification-specific, so reviewing them on their own may be easier:flet buildExtension build settings: an extension can ship a
flet-extension.tomldeclaring the Android compile options and Gradle dependencies its Flutter package needs. These are applied to every app that installs the extension, with the app's ownpyproject.tomlwinning (documented inwebsite/docs/extend/user-extensions.md).flet create --template extensionscaffolds a commented one. Manifest entries come from the Flutter plugin's ownAndroidManifest.xmlthrough the manifest merger, as for any plugin.flet-notificationsships this one:New Android settings:
compile_options,gradle_dependencies, manifestreceiverandserviceentries, andres_dirfor app-provided resources (a notification icon or sound), which are kept in release builds:iOS entitlements:
[tool.flet.ios.entitlement], or--ios-entitlementson the command line:Template context: settings now reach the template unrendered as
cookiecutter._options/cookiecutter._pyproject, so numbers keep their types and{{in a value no longer breaks the build. This breaks custom--templateauthors (see below).Startup fix: built apps no longer show a blank page when the OS suspends them while Python starts, as iOS does when launching an app in the background for a notification action.
Windows
-Embedding: built apps ignore the-Embeddingargument COM adds when Windows starts them for a notification; it was taken as a dev-mode page URL, leaving a blank window.Default bundle ID:
flet buildnow resolves the default bundle ID (<org>.<project slug>, orgcom.flet) itself instead of leaving it to the template. With nobundle_idset, the build used to name a Linux app's iconsNone.png, and skipSERIOUS_PYTHON_BUNDLE_ID, leaving the iOS frameworks built from the app's packages under shared identifiers (bug:ITMS-91065 Missing signature for _ssl.framework and _hashlib.framework in iOS IPA built with Flet 0.86.2 #6724). The template no longer derives it, so the two can't drift.flutter doctorfix: a build that fails before the Flutter SDK is found no longer crashes with aTypeErrorinstead of reporting the error.flet pack-vshows progress and PyInstaller'sINFOlog,-vvitsDEBUGlog.data/app_icon.ico, which Windows notifications use.Core and client
T | Noneannotations (onlyOptional[T]worked before).FilePickerdialogs no longer fail with a timeout after an hour open. The fixed timeouts on permission requests and file dialogs are gone.flet_notifications. The plugin registrants and the iOSAppDelegateare updated.Docs
FLET_DESKTOP_FLAVOR.Breaking change
Custom
flet buildtemplates must readcookiecutter._optionsandcookiecutter._pyprojectinstead ofcookiecutter.optionsandcookiecutter.pyproject. Nothing else here has shipped before.Known limitations
showWhenLocked/turnScreenOnonMainActivity, which would need an opt-inflet buildsetting. Documented onAndroidOptions.full_screen_intent.flet runandflet pack: taps and actions reach the app only while it's running; clicking a notification after the app has closed doesn't start it. Windows can only start aflet buildapp, which runs its own Python; the Flet client offlet runandflet packneeds Python to start it with the app.Testing
flet build(Android, iOS, template, extension settings) andflet pack.