搜索插件、代码仓与 APP 分类

windows_notification 封面
插件详情v1.3.0

windows_notification

flutter windows 通知,能够在 Windows 上发送所需模板的通知。

Windows
近 30 天下载
3380
喜欢数
86
Pub 分数
160

安装插件

flutter pub add windows_notification

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

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 mode
final _winNotifyPlugin = WindowsNotification(applicationId: "r"{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}\WindowsPowerShell\v1.0\powershell.exe"");


// create new NotificationMessage instance with id, title, body, and images
NotificationMessage message = NotificationMessage.fromPluginTemplate(
      "test1",
      "TEXT",
      "TEXT",
      largeImage: file_path,
      image: file_path
);


// show notification    
_winNotifyPlugin.showNotificationPluginTemplate(message);

Notification with imge and large image

fix2

Notification with imge

fix3

notification without any image

fix1

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

Several examples of these templates

const String template = '''
<toast activationType="protocol">
  <visual>
    <binding template="ToastGeneric">
      <text>Weather app</text>
      <text>Expect rain today.</text>
      <group>
        <subgroup hint-weight="1" hint-textStacking="center">
          <text hint-align="center" hint-style="header">15°</text>
          <text hint-align="center" hint-style="SubtitleSubtle">Rainy</text>
        </subgroup>
        <subgroup hint-weight="1">
          <text hint-align="center">Mon</text>
          <image src=".\image.jpg" hint-removeMargin="true" />
          <text hint-align="center">15°</text>
        </subgroup>
        <subgroup hint-weight="1">
          <text hint-align="center">Tue</text>
          <image src=".\image.jpg" hint-removeMargin="true" />
          <text hint-align="center">17°</text>
        </subgroup>
        <subgroup hint-weight="1">
          <text hint-align="center">Wed</text>
          <image src=".\image.jpg" hint-removeMargin="true" />
          <text hint-align="center">21°</text>
        </subgroup>
      </group>
    </binding>
  </visual>
</toast>
''';

    NotificationMessage message =
        NotificationMessage.fromCustomTemplate("notificationid_1", group: "weather_group");
    _winNotifyPlugin.showNotificationCustomTemplate(message, template);
An image of the notification related to the above code

weather

    const String template = '''
<?xml version="1.0" encoding="utf-8"?>
<toast launch="callLaunchArg" scenario="incomingCall" activationType="protocol">
  <visual>
    <binding template="ToastGeneric">
      <text>ASGHAR CALL</text>
      <text>Incoming Call</text>
      <group>
        <subgroup hint-weight="1" hint-textStacking="center">
          <text hint-align="center" hint-style="Header">GHASEM</text>
          <image src=".\image.jpg" hint-crop="circle" hint-align="center" />
        </subgroup>
      </group>
    </binding>
  </visual>
  <actions>
    <action content="Text reply" imageUri="" activationType="protocol" arguments="callReply" />
    <action content="Ignore" imageUri="" activationType="protocol" arguments="callIgnore" />
    <action content="Answer" imageUri="" activationType="protocol" arguments="callAnswer" />
  </actions>
</toast>
''';

    NotificationMessage message =
        NotificationMessage.fromCustomTemplate("notificationid_1", group: "weather_group");
    _winNotifyPlugin.showNotificationCustomTemplate(message, template);
An image of the notification related to the above code

4

Delete all notifications sent by you from Windows Action Center
 _winNotifyPlugin.clearNotificationHistory();
 
Delete notifications group sent by you from Windows Action Center

When creating an instance of NotificationMessage , it is possible to add group to the notification

   _winNotifyPlugin.removeNotificationGroup("groupname");
 
Delete single notification with id and group

When creating an instance of NotificationMessage , it is possible to add group and ID to the notification

  _winNotifyPlugin.removeNotificationId("notificationid", "groupname");
 
Events and argruments

To receive your notification events, you must use the initNotificationCallBack method

   _winNotifyPlugin.initNotificationCallBack(
        (NotificationMessage data, EventType eventType, String? arguments) {});

Launch option

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.

所属分类

依赖

依赖清单 1 项

  • plugin_platform_interface^2.1.8

源码仓库

使用此插件的项目

暂无相关数据。