Can a web app give desktop notification

大憨熊 提交于 2019-12-03 20:20:32

The desktop notification is not language dependant. There is no server-side language that can make a notification appear on a desktop. It doesn't matter what you put on the server, you can't make that code put notifications on the desktop unless the client supports such a notification API.

Client support means there has to be some sort of application running on the client that can put up the notification dialog on the desktop. This is the number one requirement.

If you don't have anything running on the client with such support, then no matter what magic you put on the server (PHP, Ruby, Perl, ...) nothing will ever happen on the client.

That's why, as you see from the answer by KCiebiera, the clients that can make notifications possible are Chrome and Firefox.

What you do is run code on the client (Javascript in this case), that looks for something (a message from the server for example), and then instructs the browser (Chrome or Firefox), to launch the notification.

It's not more complicated than that. Look at the tutorial KCiebiera posted, and that should get you started.

Hope this helps you understand the problem better.

AFAIK desktop notifications are available only in Chrome/Chromium and Firefox browser. There is a working draft http://www.w3.org/TR/notifications/ and also a great tutorial http://www.html5rocks.com/en/tutorials/notifications/quick/ on how to use them. Basically you have to learn a JavaScript API.

What goes on the server-side is irrelevant here, as the notifications happen client-side. Desktop notifications are currently part of a W3C working draft, and are implemented in the current version of Chrome and the next release versions of Firefox, Safari, & IE; see the compatibility table for more details. There are plenty of tutorials out there on how to implement this.

You would have to implement on the server some method that the client-side can use to get (or be pushed) the notifications so that it can display them using the above mentioned API. It doesn't matter if your use Rails, PHP, C++, whatever, they can all do it with enough effort.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!