windows_notification 包使 Flutter 应用程序能够在 Windows 上使用可自定义模板发送系统通知。它与 Windows 通知 API 集成,允许开发者显示带有标题、消息以及富内容(如图像和按钮)的气泡通知。该包非常适合需要及时用户提醒或状态更新的桌面应用程序。它支持简单和高级的通知布局,适用于生产力工具、消息应用和后台服务。该包轻量级且专为 Windows 平台设计。
适合场景
发送应用警报
显示系统通知
用户活动提醒
后台任务通知
实时更新显示
主要特点
可自定义的通知模板
对富文本内容(如图片)的支持
与 Windows 通知 API 的集成
简单直观的 API
Windows 平台特定
适合对象
Windows 桌面应用
生产力工具
消息应用
后台服务
系统监控工具
使用建议
仅限 Windows 平台
需要 Windows 10 或更高版本
不支持 Linux 或 macOS
通知行为可能因 Windows 版本而异
在某些环境中,可能需要配置权限
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
A library for sending notifications on Windows using Flutter
Features
Sending notifications by ready-made templates of the plugin
Send notifications by user-created templates
Receive notification events sent
Delete all notifications sent by you from Windows Action Center
Delete notifications group sent by you from Windows Action Center
Add deep link to notification
Usage
Send notification with plugin template
Sending notifications through the plugin's own templates, there are currently 3 template available in the plugin.
import'package:windows_notification/notification_message.dart';
import'package:windows_notification/windows_notification.dart';
// Create an instance of Windows Notification with your application name// application id must be null in packaged modefinal _winNotifyPlugin = WindowsNotification(applicationId: "r"{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}\WindowsPowerShell\v1.0\powershell.exe"");
// create new NotificationMessage instance with id, title, body, and imagesNotificationMessage message = NotificationMessage.fromPluginTemplate(
"test1",
"TEXT",
"TEXT",
largeImage: file_path,
image: file_path
);
// show notification
_winNotifyPlugin.showNotificationPluginTemplate(message);
Notification with imge and large image
Notification with imge
notification without any image
Send notification with custom template
You can use the template made by you to send the notification
You can find a lot of templates code with a simple search on the Internet
The Launch option allows you to embed your app's deep leak into the notification, and the target user will be redirected to the relevant page by tapping on the notification.
NotificationMessage message = NotificationMessage.fromPluginTemplate(
"test1", "You Win", "Tap to receive a gift",
launch: "my-app-schame://page1");
_winNotifyPlugin.showNotificationPluginTemplate(message);
Feature requests and bugs
Please file feature requests and bugs at the issue tracker.
If you want to contribute to this library, please submit a Pull Request.