JavaScript 浏览器通知 push.js 的用过吗?

hunter · October 31, 2016 · Last by huacnlee replied at October 31, 2016 · 5336 hits

发现一个桌面通知项目:

只要调用这么一段 js 代码,就可以发送通知给桌面? Push.create("Hello world!", { body: "How's it hangin'?", icon: 'icon.png', timeout: 4000, onClick: function () { window.focus(); this.close(); } });

我的问题:

  • 后台如果是 ruby 的,如何调用这个 js 代码?
  • 这里并没有告诉它发送给哪一个浏览器?难道这个是纯浏览器上的通知方案?

另外,求推荐简单的桌面通知方案。

  • 可以用message_bus这个 gem,ruby-china 好像用的这个 gem
  • the Notification API allows modern browsers such as Chrome, Safari, Firefox, and IE 9+ to push notifications to a user's desktop

这个是浏览器(for 客户端)的呀。

后端发送消息,不管是用 Action Cable 还是 message_bus,当消息到了客户端,再调用 push.js 就可以了。

You need to Sign in before reply, if you don't have an account, please Sign up first.