maildev
maildev copied to clipboard
Notification on receive
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.
Nice idea - I've been meaning to check out how to use desktop notifications. I'll do some reading tonight :)
I've used this in the past for angular applications. Seems to work well and it's pretty simple to get working.
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.
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 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.
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:
Ahhhh I see! It uses GCM to manage push notificatioma. Very cool! I may have a tinker with this during lunch.
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:
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.