GithubHelp home page GithubHelp logo

leanflutter / local_notifier Goto Github PK

View Code? Open in Web Editor NEW
68.0 2.0 30.0 230 KB

This plugin allows Flutter desktop apps to notify local notifications.

License: MIT License

Dart 10.98% CMake 12.42% C++ 69.98% C 1.81% Swift 3.37% Ruby 1.43%
flutter-desktop local-notification

local_notifier's Introduction

local_notifier

pub version

This plugin allows Flutter desktop apps to displaying local notifications.


English | 简体中文


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Screenshots

macOS Linux Windows
image

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  local_notifier: ^0.1.6

Or

dependencies:
  local_notifier:
    git:
      url: https://github.com/leanflutter/local_notifier.git
      ref: main

Linux requirements

  • libnotify

Run the following command

sudo apt-get install libnotify-dev

Usage

// Add in main method.
await localNotifier.setup(
  appName: 'local_notifier_example',
  // The parameter shortcutPolicy only works on Windows
  shortcutPolicy: ShortcutPolicy.requireCreate,
);

LocalNotification notification = LocalNotification(
  title: "local_notifier_example",
  body: "hello flutter!",
);
notification.onShow = () {
  print('onShow ${notification.identifier}');
};
notification.onClose = (closeReason) {
  // Only supported on windows, other platforms closeReason is always unknown.
  switch (closeReason) {
    case LocalNotificationCloseReason.userCanceled:
      // do something
      break;
    case LocalNotificationCloseReason.timedOut:
      // do something
      break;
    default:
  }
  print('onClose ${_exampleNotification?.identifier} - $closeReason');
};
notification.onClick = () {
  print('onClick ${notification.identifier}');
};
notification?.onClickAction = (actionIndex) {
  print('onClickAction ${notification?.identifier} - $actionIndex');
};

notification.show();

Please see the example app of this plugin for a full example.

Who's using it?

Related Links

License

MIT

local_notifier's People

Contributors

carapacik avatar lijy91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

local_notifier's Issues

Install libnotify got error in ubuntu

Hi, there!
I develope flutter application on ubuntu, I want to use local_notifier, but when I run the following command :

sudo apt-get install libnotify-dev

I got the error:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libgdk-pixbuf2.0-dev : Depends: libgdk-pixbuf2.0-0 (= 2.40.0+dfsg-3ubuntu0.4) but it is not going to be installed
                        Depends: libgdk-pixbuf2.0-bin (= 2.40.0+dfsg-3ubuntu0.4)
                        Depends: gir1.2-gdkpixbuf-2.0 (= 2.40.0+dfsg-3ubuntu0.4) but 2.42.6+dfsg-1build2 is to be installed
                        Depends: libglib2.0-dev (>= 2.37.6) but it is not going to be installed
                        Depends: libx11-dev but it is not going to be installed
                        Depends: libpng-dev (>= 1.6) but it is not going to be installed
                        Depends: libpng-dev (< 1.7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Any suggestion to me?

maybe following info is useful:

xxx@yyy:~$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.3, on Ubuntu 21.10 5.13.0-19-generic, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio
[✓] VS Code (version 1.71.0)
[✓] Connected device (1 available)
HTTP Host availability check is taking a long time...[☠] HTTP Host Availability (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
      https://github.com/flutter/flutter/issues.
    ✗ Exception: HTTP Host Availability exceeded maximum allowed duration of 0:10:00.000000

! Doctor found issues in 3 categories.

Action when click

I Love this package,
Is it possible support action when user click notification ?

Error when call notification.show()

Code:

LocalNotification notification = LocalNotification(
  title: item.reason,
 );

notification.show();

xml: <toast scenario="Default"><visual><binding template="ToastText02"><text id="1">content</text><text id="2"></text></binding></visual></toast>

[Linux][0.1.3] Build failed with error

When I run app, those errors shows up and causes build failed.
I add include <string> in local_notifier_plugin.cc , the error disappeared and works. But I am not sure if this is the right fix.

/home/stonegate/Flutter/jenkins-board/linux/flutter/ephemeral/.plugin_symlinks/local_notifier/linux/local_notifier_plugin.cc:20:10: error: no member named 'string' in namespace 'std'; did you mean 'stdin'?
/home/stonegate/Flutter/jenkins-board/linux/flutter/ephemeral/.plugin_symlinks/local_notifier/linux/local_notifier_plugin.cc:20:15: error: template argument for template type parameter must be a type
/home/stonegate/Flutter/jenkins-board/linux/flutter/ephemeral/.plugin_symlinks/local_notifier/linux/local_notifier_plugin.cc:125:17: error: no member named 'string' in namespace 'std'; did you mean 'stdin'?
/home/stonegate/Flutter/jenkins-board/linux/flutter/ephemeral/.plugin_symlinks/local_notifier/linux/local_notifier_plugin.cc:125:22: error: template argument for template type parameter must be a type

Can you please have a check?
Thanks!

web support

since there is no package support web local notify it will be big deal if this package support

it creates a shortcut in the windows startmenu dir

I absolutely love this and most of your packages
but when I display the notification it creates a shortcut (.lnk) in the startup menu in the windows with the name being the title of the notification
and it's linked to the executable

is there any way to prevent this from creating or change the path that this file gets created

here are the prints in the flutter app

Default App User Model Id: <notification-name>
Default shell link path: C:\Users\<UserName>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
Default shell link file path: C:\Users\<UserName>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\<notification-name>
xml: <toast scenario="Default"><visual><binding template="ToastText02"><text id="1">test</text><text id="2">test is gonna be ringing at 12:40</text></binding></visual></toast>

thanks 😀😀

[Windows] No logo

The logo area is blank on Windows.

Side note
Have you considered making a PR with flutter_local_notifications for an all in one notification package?

Add support for Dart SDK

Please add support for Dart SDK, i need to send notifications from my dart service that runs on the background.
Or if its not possible with this package create a different one.

[macOS] Notification is not shown if the app is in foreground

Often this might be the exepcted behaviour as the notificaiton could also be displayed in your app. But what if the app is only living in the tray using tray_manager or similar?

The behaviour could be configurable in the plugin and maybe even default to always show the alert?
Documentation is here.

This would hardcode the behaviour to always show the alert:

diff --git a/macos/Classes/LocalNotifierPlugin.swift b/macos/Classes/LocalNotifierPlugin.swift
index 2ac7d7e..bdfea72 100644
--- a/macos/Classes/LocalNotifierPlugin.swift
+++ b/macos/Classes/LocalNotifierPlugin.swift
@@ -83,6 +83,10 @@ public class LocalNotifierPlugin: NSObject, FlutterPlugin, NSUserNotificationCen
     public func userNotificationCenter(_ center: NSUserNotificationCenter, didDeliver notification: NSUserNotification) {
         _invokeMethod("onLocalNotificationShow", notification.identifier!)
     }
+
+    public func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
+      return true
+    }
     
     public func _invokeMethod(_ methodName: String, _ notificationId: String) {
         let args: NSDictionary = [

Support for web?

Hi! i am unable to run web when i have this packages, is there a way to fix that?

Support macOS < 10.15

It would be nice if this plugin could support macOS older than 10.15. Currently the podspec file requires 10.15.

Windows version

It is very useful package, easy use.
Is it possible support windows?

Toast Not Showing and only print xml code on terminal

xml: examplehello flutter!
flutter: onShow _exampleNotification
xml: example - 0hello flutter!
flutter: onShow 07afb153-163c-472b-8698-cbf777562664
flutter: onClose 07afb153-163c-472b-8698-cbf777562664 - LocalNotificationCloseReason.unknown
xml: example - 0hello flutter!
flutter: onShow 07afb153-163c-472b-8698-cbf777562664

Support all win platform

I have implemented a pop-up window that supports the whole platform and is perfectly compatible with the current component api.

It use win32 api to implemented it.

Like this:
image

I think that this is so cool.

Because of the company, I can't open source code, but I can provide some ideas if you need support

Of course, my implementation is not perfect. For example, circular sawtooth, key flashing, etc

Typo in destroy function

A little type on notification function, it should be destroy same as destroy function on instance.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.