maildev icon indicating copy to clipboard operation
maildev copied to clipboard

Notification on receive

Open turt2live opened this issue 10 years ago • 9 comments

I didn't find any reference to this being supported, but it would be nice to have a desktop notification be sent when an email is received.

turt2live avatar Jun 18 '15 14:06 turt2live

Nice idea - I've been meaning to check out how to use desktop notifications. I'll do some reading tonight :)

Seidr avatar Jun 18 '15 14:06 Seidr

I've used this in the past for angular applications. Seems to work well and it's pretty simple to get working.

turt2live avatar Jun 18 '15 14:06 turt2live

Hey @turt2live! Very interesting idea, with this plugin the tab would have to be open when an email is received right? I'm guessing w/ it being in Angular it has to be open in a tab to ping the notification API.

I'm thinking we could do something on the backend side of things, perhaps with https://www.npmjs.com/package/node-notifier - it would only really work if you're running it on your own machine though and not when running MailDev on a dev server.

djfarrelly avatar Jun 18 '15 23:06 djfarrelly

It doesn't have to be open, I used it for a small chat application. So long as the user grants access to notifications then it can be sent. This is assuming that there's no logic in place to pause JavaScript execution when the tab is hidden though.

turt2live avatar Jun 18 '15 23:06 turt2live

@turt2live The tab still has to be open in order to receive the websocket message though, surely? Even web workers will go away a short time after the tab is closed, even if they're running expensive jobs. If that's not the case, I'd be curious to know the transport that you've used that receives the message, and as such triggers the client side notification.

With regards to JS pause behaviour, I know Chrome can be a little tricky in this regard, but it seems to be dealing with websocket notifications quite well, so my hope is that if the notification calls are put in the websocket receiver, then the tab will be awake long enough to fire the notification.

Seidr avatar Jun 19 '15 10:06 Seidr

Chrome 42+ supports push notifications now, which can work with the tab closed: https://developers.google.com/web/updates/2015/03/push-notificatons-on-the-open-web?hl=en

If you were going to implement a feature like this though, make sure it's optional :smiley:

cbdabner avatar Jul 02 '15 00:07 cbdabner

Ahhhh I see! It uses GCM to manage push notificatioma. Very cool! I may have a tinker with this during lunch.

Seidr avatar Jul 02 '15 05:07 Seidr

Good digging. GCM would likely mean we'd need to have each person using MailDev have a unique key so we don't get each other's notifications! If we implement this, I'm kind of liking node-notifier to keep it simpler and keep it on the OS level and not involve GCM. Using node-notifier also allows us to be browser-agnostic which is a plus :wink:

djfarrelly avatar Jul 15 '15 16:07 djfarrelly

I think desktop notifications are the best start. I don't think a reliance on GCM is good. I think node-notifier is great, but I run maildev in a Docker container so that won't help me. I can always pin the tab though, so that's what I'd vote for if you're prioritizing it.

joshuaadickerson avatar Feb 01 '17 23:02 joshuaadickerson