Implement desktop notifications [$100 awarded] #27

Closed
zcbenz opened this Issue Aug 26, 2012 · 111 comments

Projects

None yet
@zcbenz
Contributor
zcbenz commented Aug 26, 2012

webkitNotifications can be implemented by overriding ShowDesktopNotification and CancelDesktopNotification in content browser client, chrome has already implemented them in chrome/browser/notifications, code can be reused there.

The $100 bounty on this issue has been claimed at Bountysource.

@zcbenz zcbenz referenced this issue Nov 23, 2012
Closed

Notification API #212

@Mithgol
Contributor
Mithgol commented Dec 22, 2012

Hyperlinks for the future docs on this feature:

@Mithgol
Contributor
Mithgol commented Dec 26, 2012

And somebody should tell that user to watch this issue.

@AndryBray

Hi! Any news about this feature? Hope yes =)

@ChaitanyaPramod

Desktop Notifications are very critical for any App to give a completely native experience. And for a chat app (which I'm trying to port from a chrome-extension), notifications are essential.
I wonder if anyone has tried the implementation suggested by @zcbenz in the description? If it looks simple enough, I might try it.

@damianb
damianb commented Jun 14, 2013

+1

@AndryBray

+1

@Anonyfox

+1

@luxueyan2008

me too

@YurySolovyov

im not sure, but chrome 28+ should have notifications http://blog.chromium.org/2013/05/rich-notifications-in-chrome.html

@damianb
damianb commented Jun 23, 2013

prior versions of chrome had it buried too under chrome://flags

@Mithgol
Contributor
Mithgol commented Jun 24, 2013

I wonder if it does really mean that they appear then in Chromium/Blink code and then in node-webkit.

@AndryBray

Please, could we know the place / priority of this feature in the roadmap?
Thank you

@Mithgol
Contributor
Mithgol commented Jun 28, 2013

@Dream707

im not sure, but chrome 28+ should have notifications http://blog.chromium.org/2013/05/rich-notifications-in-chrome.html

That's rich notifications for Chrome packaged apps and extensions. A different thing.

Here we are talking about HTML5 Notifications API.

The real issue here is that typeof Notification === 'function' already (in node-webkit 0.6.1) and that you can call new Notification('some test'), but nothing happens.

@YurySolovyov

maybe just a flag somewhere in build config or something? or some permission issues(you have to ask a permission in order to display notification)

@rogerwang
Member

Hello, thanks for your patience.

The reason this feature is in Chromium but not in node-webkit is: The feature is implemented in the Chromium browser, which is built on Content Layer, on which is node-webkit built. (node-webkit is on the same level with the browser part of Chromium.) So code for this is not in node-webkit.

I planed to move it to node-webkit but recently it's under refactoring to a new component (message center) in upstream. The good news is that the new component is more Content Layer friendly so it would make the move easier. Now the plan is to provide this feature in node-webkit 0.7.x or 0.8.x if upstream makes it ready on all the 3 platforms.

@Mithgol
Contributor
Mithgol commented Jun 30, 2013

Thank you for explaining the current state of things.

@miklschmidt

That sounds great @rogerwang thanks for the update!

@damianb
damianb commented Jun 30, 2013

Please keep us posted - I guess we'll have to individually work around this and come up with some sort of temporary solution on our own.

For linux, at least, we've got notify-send.

@miklschmidt

My extremely dependency heavy take at a workaround is here: https://gist.github.com/miklschmidt/5896306 if it's useful to anyone.

@damianb
damianb commented Jun 30, 2013

@miklschmidt That's quite helpful, thanks! I'll probably have to pick it over myself to make it a bit more agnostic, but that is a great start.

I take it vendor/tween is tween.js?

Also - what is lib/gui?

@miklschmidt

tween.js is TWEEN.js https://github.com/sole/tween.js/

lib/gui is just a require.js wrapper for require('nw.gui') i like to avoid using two types of dependency declarations in the same file :)

@vlados
vlados commented Aug 18, 2013

How we can help so this can be integrated as soon as possible?

@mbrevda
mbrevda commented Aug 26, 2013

+1

@whoamicz
whoamicz commented Sep 3, 2013

+1

@mschaaf
mschaaf commented Sep 10, 2013

👍

@zh99998
zh99998 commented Sep 21, 2013

zh99998 +1'd this post.

@trevorlinton

@rogerwang I have an initial patch that supports MacOSX Lion style notifications, i'm adding bubble notifications shortly (before Nov. 19th) and support for badges. You can see an initial commit here: trevorlinton@0575208

@jtenner
jtenner commented Oct 8, 2013

+1 on this. I can't wait to demo this for my boss.

@vlados
vlados commented Oct 8, 2013

@trevorlinton, @rogerwang when we can use it?

@dubcanada

I can implement this for GTK if you want @trevorlinton just let me know and I'll submit a pull request.

@damianb
damianb commented Oct 9, 2013

@dubcanada Curious, would GTK listen to libnotify notifications? If it does, that might be a better idea, to save on code redundancy.

@damianb
damianb commented Oct 9, 2013

@dubcanada Thank you, wasn't sure. :)

@rogerwang
Member

Thanks for contributing! A solution based on message center in upstream is preferred. I'm working to port it from Chromium but unfortunately it's unlikely to catch 0.8.0 timeframe since upstream released Chromium 30 earlier than expected. I need to release 0.8.0 sooner to catch up.

@rogerwang
Member

btw, we have a rule in this project that native features need to be implemented on all the 3 platforms before merging into master (unless the feature is really platform specific), or we'll have nightmare of a complex matrix of which feature works on which platform.

@semmel
semmel commented Oct 10, 2013

If "a solution based on message center in upstream" will look like the notifications a website can display right now in Google Chrome 31 beta, it will be perfect:
Using the comprehensive standards API http://notifications.spec.whatwg.org really simplifies things. :-)

@dubcanada

The message center is based on the desktop notification API for chrome http://www.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development/desktop-notification-api so yes it would function exactly like it does in Chrome (when ever they update their notification API to the newest version). Plus it would look the exact same across all platforms. The other solution by trevorlinton is different on each OS (uses the native solution vs the Chrome made solution). It would function like http://www.dangercove.com/html5-notifications/

Though we would need to remove all the permission stuff.

@rogerwang I can help work on a solution from Chromium 30 if you would like. When do you expect Chromium 30 merged in?

@rogerwang
Member

@dubcanada it would be great if you can help on it. I plan to release 0.8.0-rc1 in 1-2 weeks.

btw, at first it's needed to investigate the dependency of message center in Chromium. IIRC it depends on Aura at least on Linux, which requires migrating our native UI stuff from gtk to Aura, which is another big part. Or we work on a solution based on Ballon first in Chromium, it's what upstream used before message center.

@damianb
damianb commented Oct 13, 2013

This may be relevant for OS X users at least, this popped up on r/node: http://www.reddit.com/r/node/comments/1oco22/termy_programmatically_send_os_x_notifications_in/

@trevorlinton

Lion/Maverick style notifications are added with this pull request: #1257 Unfortunately it is not the standard "Notification" spec.

@trevorlinton

Windows XP+ balloon notifications patch can be found here (for anyone interested):

trevorlinton@c655c21

@VeoPVM
VeoPVM commented Nov 16, 2013

Any news when these notifications will be available?

@Programming4life

If only I know c++/c i would fix thissss. Omg

@dubcanada

@rogerwang

Is Aura stuff in node-webkit yet? Or should I use ballon?

@dubcanada

@rogerwang any ideas on the Aura stuff in node-webkit?

@cyrilis
cyrilis commented Dec 11, 2013

+1. Any good news?
The latest release seems not work.

@binchem
binchem commented Dec 17, 2013

+1. Any good news?

@lizongzhi

+1

@dubcanada

Still waiting to hear from @rogerwang if Aura is making it's way in or not.

@JohnnieFucker

+1,is there any news of this feature?

@goloroden

+1

@puroturo

+1 @rogerwang regardless of status, possible to get an update? Thinking about perhaps looking into it ourselves (or even assess feasibility), but certainly don't want to duplicate efforts if there's any headway here..

@rogerwang
Member

There is no effort on this here yet. Welcome to contribute if you'd like to.

@ixi
ixi commented Jan 19, 2014

+1

@duralog duralog referenced this issue in Circadio/circadio-issues Jan 26, 2014
Open

annoying messages #33

@jninja
jninja commented Jan 29, 2014

+1

@mwitte
mwitte commented Feb 12, 2014

+1

@FrankFang

+1

@jamesmortensen

I needed notifications. So I've implemented something that may help. I'm also porting a chromium-app to node-webkit. I didn't want to rewrite all my business logic, so I stubbed out all of the API's I was using and then either wrapped node-webkit functions inside them or left them unimplemented. To handle the notifications, I grabbed the nw-desktop-notifications library and wrapped that library up in the webkitNotifications API so that the interfaces are preserved, as if I were using the standard HTML5 webkitNotifications.

The node-webkit-chrome-api-stubs is a chromium-app that also runs as a node-webkit app. If you include the nw-desktop-notifications, you'll have notifications in your node-webkit app, using the webkitNotifications API for a seamless transition.

I know this isn't built into node-webkit since there are dependencies you would need to include in your app, but I'm hoping it will help.

@damianb
damianb commented Feb 14, 2014

Might want to adjust nw-desktop-notifications library yourself, it's not going to work well without internet - it's using jquery 1.9 from googleapis

@jamesmortensen

@damianb - Thanks for pointing that out; I'll add that to my patch. I didn't want to include the entire library until the owner updates the license. That's why I've left it up to the implementor for now.

@dubcanada

The intention was to use the native Chromium desktop notifications.

@jamesmortensen

@dubcanada - Yeah, thanks. I get that. My goal is to help others and hopefully reduce the number of "+1 - me too's" that are appearing in this thread. Obviously, this doesn't fix the overall problem.

@damianb
damianb commented Feb 15, 2014

@dubcanada In the meantime, having a "works well enough" solution is nice.

@wells1013

+1

@imjoshdean

👍 What's the status on this?

@ccarlsen
ccarlsen commented Apr 8, 2014

Really need to know status on this as well.

@epingchow

+1

@Mithgol
Contributor
Mithgol commented Apr 15, 2014

The status seems the same as three months ago.

@sandaemc

+1

@MaDetho
MaDetho commented Apr 22, 2014

+1

@zcbenz zcbenz changed the title from Implement desktop notifications to Implement desktop notifications [$50] Apr 25, 2014
@zcbenz zcbenz added the bounty label Apr 25, 2014
@hachre
hachre commented May 5, 2014

+1

@zcbenz zcbenz changed the title from Implement desktop notifications [$50] to Implement desktop notifications [$100] May 8, 2014
@zcbenz zcbenz added the bounty label May 8, 2014
@necccc
necccc commented May 12, 2014

+1

@jtg-gg
Member
jtg-gg commented Jun 10, 2014

I've implemented it and made a pull request
#1951

@SSilence

+1

@iampuma
iampuma commented Jun 12, 2014

+1 #1951 looks good so far!

@donbeave

Notifications looks cool!

@jtg-gg
Member
jtg-gg commented Jun 17, 2014

I've made a release build for anyone wants to try
https://github.com/jtg-gg/node-webkit/releases/tag/nw-v0.9.2-jtg-gg

@jamesmortensen

@jtg-gg Thank you for working on this! This is awesome! I downloaded and got it working right away using the stock API's.

On Mac, here's what it looks like with a stock logo:

screen shot 2014-06-16 at 10 00 55 pm

On Mac OS, do you know if it's possible to ditch the node-webkit logo? I am currently using node-notifier, which is built on top of terminal-notifier in Ruby, which uses AppleScript under the hood, (quite the rabbit hole), and I can replace the image on the left with my own.

I went so far as to replace nw.icns with our own, just to see if that controls the notification icon, and it doesn't seem to affect it.

On Windows, it looks great! Here's what it looks like there:

screen shot 2014-06-16 at 11 50 46 pm

The placeholder image I used in the notifications is sourced from here: freeimages.co.uk.

@jtg-gg
Member
jtg-gg commented Jun 17, 2014

hi @jamesmortensen for MAC icon, have you tried to change your main app icon ?
if that doesn't work, I'll look into it when I have time

@adam-lynch
Member

@jtg-gg sorry, what is this? node-webkit with built in notifications? Would it pass Mac App Store inspection?

@jamesmortensen FYI, if you plan on going into the MAS: see Teamwork/node-notifier-allowed-in-mac-app-store

@jamesmortensen

@jtg-gg - Sorry for delayed response. Yes, I replaced the icon in the manifest, as well as in the actual .app package as per https://github.com/rogerwang/node-webkit/wiki/Icons. In the screenshots in my previous comment, you can see the replaced icon is there on the right side, but the default node-webkit icon shows up on the left side.

@jamesmortensen

@jtg-gg - The other issue is that only local paths for the image seem to be supported. HTTP urls and BLOB urls fail to render. I was hoping to be able to show a person's face as the image, and this would of course be dynamic and pulled from our server.

@pbojinov

Check out nodeifications as an alternative to nw-desktop-notifications, I forked it to look like the Chrome native notifications and it follows a similar API to the Chrome notifications API. All the deps are local.

While it doesn't fully solve the problem, it worked in my situation. Hope it helps!

Image Notification

@zhailei31665431

@jtg-gg hello , When reminded out, the main program can be awakened to the desktop top, how does it come out

@joshleaves

@jamesmortensen @jtg-gg I managed to replace the default node-webkit icon in the notifications with my own icon. You need to edit the Info.plist in the packaged app and replace the value for the key "CFBundleIdentifier" with your own bundle identifier.

Best guess is that this may be related to some sort of caching by Mac OS X, in the same way that sometimes, even replacing the whole nw.icns will still display the default icons.

@joshleaves

@jtg-gg On Mac OS X Mavericks, by default, the notifications settings are set to "Banner" (aka "Display me for five seconds then hide into the notifications center"-mode). Is there a way to force the notifications settings for the app to "Alerts" (aka "stay visible until the user interacts with me"-mode) from within the app?

@stephan-nordnes-eriksen

@pbojinov Is it possible to install nodeifications with npm or bower?

@jamesmortensen

@jtg-gg - One problem we're facing is the sounds that are played with these notifications. I have users that don't under any circumstances want sound notifications. Additionally, for users who do want sounds, we use different sounds to notify users of different types of events (i.e incoming chat or call or some other event that requires attention).

With the current implementation, it appears you've hard-coded a sound when displaying the Web Notifications.

I checked Firefox and Chrome, and neither of those platforms play sound on their Web Notifications. Can we get those turned off for these? If someone wants to play a sound when showing a notification, they could just play a sound using the <audio> element. There's also the Web Audio API, which works in node-webkit.

Alternatively, if you're intimately tied to your implementation -- as many developers are with their code -- perhaps you could add a property to the Notification options to enable sound, if desired (but turn them off by default to comply with the Web Notifications spec).

Thank you again for putting this together!

@jamesmortensen

UPDATE: I tried the notifications on Ubuntu 12.04. There are no sounds, as expected. Also, when testing on Windows 8/8.1 there were no sounds. It seems this problem with unwanted sound only exists on Mac. Hope this helps!

@duralog
duralog commented Aug 24, 2014

in file src/nw_notification_manager_mac.mm comment out line 135 and you should be fine... adding sounds probably would best be done instead with the audio api

@jorgeolivero

+1

@jtg-gg
Member
jtg-gg commented Sep 3, 2014

I agree with you @jamesmortensen, I've made a pull request #2289

@victorzimmer

+1

@rogerwang rogerwang closed this Sep 10, 2014
@rogerwang rogerwang added the bounty label Sep 10, 2014
@adam-lynch
Member

Closed? Sorry, maybe I'm wrong, but are you settling for those tray tooltips on Windows?
image

IMO, they're not a good enough. Doesn't look like a real notification, can't show more than one at once, Windows is moving towards a different style notification since Windows 8, etc.

@edjafarov

Just published replacement for rich desktop notifications check live -http://screencast.com/t/bUxB6vNvW8BN

https://github.com/edjafarov/node-webkit-desktop-notification
html5 Notification like API, better animations.

@yoshuawuyts yoshuawuyts added a commit to yoshuawuyts/node-webkit-builder that referenced this issue Sep 19, 2014
@yoshuawuyts yoshuawuyts gulpfile: update
Fixes an issue with node-webkit notifications -- nwjs/nw.js#27 (comment)
a10a173
@yoshuawuyts yoshuawuyts referenced this issue in nwjs/nw-builder Sep 19, 2014
Merged

gulpfile: update #80

@edjafarov

html5 notification ubuntu
screen shot 2014-09-20 at 8 33 33 pm

@J-Rojas
J-Rojas commented Sep 26, 2014

Hello, I've tried node-webkit v0.10.5 on Windows 7 (64 bit), Service Pack 1. When trying to create a new Notification, node-webkit crashed. This occurred with both a local script bundled into the application and also in an IFrame. Notifications on MacOSX and Ubuntu both worked.

If someone has had success on Windows 7, can you share what version of the OS and version of node-webkit worked for you. Thanks.

@sergiovilar

@joshleaves @jamesmortensen @jtg-gg this works fine! Thanks!

@adam-lynch adam-lynch added a commit to nwjs/nw-builder that referenced this issue Oct 29, 2014
@yoshuawuyts @adam-lynch yoshuawuyts + adam-lynch gulpfile: update
Fixes an issue with node-webkit notifications -- nwjs/nw.js#27 (comment)
411cbb3
@rogerwang rogerwang changed the title from Implement desktop notifications [$100] to Implement desktop notifications Dec 15, 2014
@rogerwang rogerwang changed the title from Implement desktop notifications to Implement desktop notifications [$100 awarded] Feb 21, 2015
@marbemac

Like @J-Rojas, I'm also seeing a crash in Windows 7 64 bit. The notifications are working fine in OS X and Linux. Does anybody have notifications working in Windows 7 (I have not tried other windows version yet)?

@jtg-gg
Member
jtg-gg commented Feb 24, 2015

@marbemac I've just tested the latest build, it works on my win 7 64 bit, hmm do you have the call stack for the crash ?

@marbemac

@jtg-gg I checked the %TEMP% folder for the crash dump as described here https://github.com/nwjs/nw.js/wiki/Crash-dump but don't see anything. Is there somewhere else I should be looking?

When it crashes Windows only gives me a "programName.exe has stopped working. a problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

I took the notification code out to make sure, and sure enough the app booted fine. Then, in the dev console, I created a new notification while the app was running and it crashed.

@marbemac

@jtg-gg I was able get the .dmp file. See this paste bin:

http://pastebin.com/869PPRku

Looks like something to do with storage.get?

[3664:0223/190703:FATAL:image.cc(748)] Check failed: storage_.get().

The code I'm using for the notification is just

new Notification("Title", {body: "Body"});

Thanks in advance for any help you can provide!

@jtg-gg
Member
jtg-gg commented Feb 24, 2015

@marbemac looks like, there is problem of getting the application icon, the notification, will try to get the application icon, if no image is specified

@victorzimmer

If it works on OSX and Linux, but not Windows with fetching an image from the file tree it sounds a lot like a path error :P


Victor Zimmer

On Tue, Feb 24, 2015 at 5:46 AM, jtg-gg notifications@github.com wrote:

@marbemac looks like, there is problem of getting the application icon, the notification, will try to get the application icon, if no image is specified

Reply to this email directly or view it on GitHub:
#27 (comment)

@marbemac

Hmm, where should I set this application icon? Is it required? If it makes any difference, I'm currently using https://github.com/mllrsohn/node-webkit-builder to build the app.

@marbemac

@victorzimmer @jtg-gg I set the winIco option in node-webkit-builder but no luck - still crashes. Any other ideas? Do Windows 7 (64) notifications work for you guys when you build with node-webkit-builder (just to rule that out)?

@jtg-gg
Member
jtg-gg commented Feb 25, 2015

@marbemac can you try, to specify some jpg/png icon (http:// or file://) when you execute the notification ?

@marbemac

@jtg-gg I updated my notification code test to the below, and it works fine in OS X, but still crashes in Windows. Any other ideas? And it's working in Windows 7 for you? This is so weird. Incidentally I did try it on another windows 7 computer and it crashed on that one as well. I've also tried several of the packaging methods listed in the wiki.

var options = {
        icon: "http://www.fnordware.com/superpng/pngtest16rgba.png",
        body: "Here is the notification text"
};

var notification = new Notification("Notification Title", options);
@marbemac

Solved, my manifest file had the window.icon set to a blank string. So many places to set an icon, I didn't notice that option in the manifest file. Thanks for the help guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment