How do push notifications work?

后端 未结 2 621
走了就别回头了
走了就别回头了 2020-12-23 12:07

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

2条回答
  •  一向
    一向 (楼主)
    2020-12-23 12:35

    Working

    HTML5rocks have provided a good explanation here, about how websockets work.

    Well you can make use of Websockets for the browsers that support it (since all modern browsers provide good support)

    Getting Started

    You can get started with these few resources :

    HTML5rocks

    Nettuts+

    Nettuts+ provide a good tutorial for getting started with websockets.

    For Browsers Supporting Websockets

    Fallback

    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.

    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.

    Any browser with Flash can support WebSocket using the web-socket-js shim/polyfill.

    Reference:

    Alternative to WebSockets

    https://softwareengineering.stackexchange.com/questions/33713/is-there-an-alternative-to-html-web-sockets-now-that-firefox-4-has-disabled-the

提交回复
热议问题