简体   繁体   English

HTML5-推送状态桌面通知

[英]HTML5 - Push Status Desktop Notification

Suppose I want to create a status report notification that check the db from time to time of the current status? 假设我要创建一个状态报告通知,以不时检查当前状态的数据库? Example: Lets say, a computer shop scenario that will show notifications 5 minutes before -- alerting the admin that the time of PC 1 is about to run out. 示例:假设某个计算机商店场景将在5分钟前显示通知-提醒管理员PC 1的时间即将用完。

I tried following this tutorial, http://beakkon.com/tutorial/html5/desktop-notification , but it needs user interaction (in this case, button click) so that desktop notifications will appear. 我尝试按照本教程http://beakkon.com/tutorial/html5/desktop-notification进行操作 ,但需要用户交互(在这种情况下,单击按钮),以便出现桌面通知。 I am using PHP, jQuery, HTML as my web technology. 我使用PHP,jQuery,HTML作为我的网络技术。

Also, Will the notification still appear even if I am not on the web page triggering the fetching of data? 另外,即使我不在网页上触发数据提取,通知仍会出现吗?

Thanks to zvona for guiding the way. 感谢zvona的指导。 The trick will be to put the notification in a page that will be accessible by other pages in that way, notification will be accessible anywhere. 诀窍是将通知放在其他页面可以通过该方式访问的页面中,通知将可以在任何地方访问。

Desktop notifications require user interaction first time, in order to allow them. 桌面通知要求用户首次互动才能允许。

But basically you create a setInterval which makes the DB query / XHR and then triggers createNotification if certain conditions are met. 但是基本上,您可以创建一个setInterval,它使数据库查询/ XHR,然后在满足某些条件时触发createNotification。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM