如何推送通知的工作? [英] How do push notifications work?
问题描述
我想实现我的基于PHP的网站推送通知。我们的目标是使类似的东西到什么#1和其他网站都该通知时,他们得到的消息实时的用户。
I'm trying to implement push notifications on my PHP-based website. The goal is to make something similiar to what Stackoverflow and other sites have which notify a user in real-time when they get messages.
我使用MySQL作为我的数据库,Apache作为我的服务器,并使用亚马逊SNS作为,因为这些通知的框架,正在考虑是什么,服务似乎打算。
I'm using mysql as my database, Apache as my server, and am considering using Amazon-SNS as the framework for these notifications since that is what that service seems to be intended for.
我有从文献很难理解如何编程的 sending.php
和 receiving.php
页都成立。我假设 sending.php
页面只是涉及 $ _ POST ['消息']
来一些网页,但从那里,我真的失去了。
I'm having a hard understanding from the literature how programmatically the sending.php
and receiving.php
pages are set up. I'd assume the sending.php
page just involves a $_POST['message']
to some page, but from there I'm really lost.
如果事情能帮助我理解 receiving.php
页会是什么样子的推送通知我将不胜AP preciate它。
If something could help me understand what the receiving.php
page would look like for a push notification I would greatly appreciate it.
推荐答案
HTML5ROCKS在这里提供了很好的解释 ,如何的WebSockets的工作。
Working
HTML5rocks have provided a good explanation here, about how websockets work.
那么你可以使用WebSockets,为支持它(因为所有现代浏览器都提供良好的支持)
Well you can make use of Websockets for the browsers that support it (since all modern browsers provide good support)
您可以开始使用这几个资源:
You can get started with these few resources :
<一个href=\"http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/\">Nettuts+
NETTUTS +入门与<一个提供一个很好的教程href=\"http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/\">websockets.
Nettuts+ provide a good tutorial for getting started with websockets.
您可以使用 Modernizr的以检测客户端的浏览器是否有支持的WebSockets与否&功放;作为后备,你可以利用闪存来代替的WebSockets的。
You can use Modernizr to detect whether the Client's browser has support for websockets or not & as a fallback you can make use of flash instead of Websockets.
有关的项目,没有的WebSockets或在浏览器中运行时,它禁用,网络插座JS 将会被使用。这将是比本地效率不高,但比长轮询仍然低得多的延迟。
For those projects, when running on browsers with no WebSockets or with it disabled, web-socket-js will be used. It will be less efficient than native, but still much lower latency than long-polling.
与Flash任何浏览器都可使用网络插座JS 垫片/填充工具支持WebSocket的。
Any browser with Flash can support WebSocket using the web-socket-js shim/polyfill.
参考:
<一个href=\"http://programmers.stackexchange.com/questions/33713/is-there-an-alternative-to-html-web-sockets-now-that-firefox-4-has-disabled-the\">http://programmers.stackexchange.com/questions/33713/is-there-an-alternative-to-html-web-sockets-now-that-firefox-4-has-disabled-the
这篇关于如何推送通知的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!