How can I detect Flash fallback problems?

We don't currently expose a standard way for detecting a Flash version problems but you can detect connection failure. You can get information on our connections state functionality in the connection state docs.

The first thing to do is to bind to the failed event and within the callback check for Flash support. The failedevent will only fire if Pusher is not supported by the browser. This implies that Flash is not available, since that is the only fallback in browsers that do not natively support WebSockets.

var pusher = new Pusher('YOUR_APP_KEY');
pusher.connection.bind('failed', function() {
  // do Flash check here
});

You can now check if Flash is available and that the appropriate version is available. Our Pusher JS library includes a few other libraries. One such library is the SWFObject library. It exposes a getFlashPlayerVersion method which returns an object on which you can access the majorminor, and release of the currently installed Flash plugin.

var flashVersionInfo = swfobject.getFlashPlayerVersion();

You can use this to detect if the Flash version is less than the required 10.0.0. This is what websocket-js does also.

var pusher = new Pusher('YOUR_APP_KEY');
pusher.connection.bind('failed', function() {
  var flashVersionInfo = swfobject.getFlashPlayerVersion();
  if(!swfobject.getFlashPlayerVersion().major >= 10) {
    console.error("Flash fallback won't work.");
  }
}
Was this article helpful?
0 out of 0 found this helpful
Haven't found what you were looking for?
Submit a ticket