WebSockets and DeviceOrientation Support in iOS 4.2
The latest release of Apple’s iOS operating system for the iPhone and iPad, version 4.2, adds support to Mobile Safari for the DeviceOrientation and WebSockets APIs.
The other addition to Mobile Safari in iOS 4.2 is support for web sockets. This is more likely to be of interest to web developers, not only because of its more general applicability but because sockets already have a good degree of support in other browsers. The WebSocket API allows for two-way communication between client and server. It’s particularly interesting for real-time applications that currently rely on some form of AJAX polling (for a great rundown of the API and why it’s awesome, check out this writeup on the Opera Developer Community blog). WebSockets are already available in Chrome and Safari, and are also found in the current betas of Firefox 4 and Opera 11. That leaves IE9, still in platform preview, which still has no support—although there’s always the hope that this functionality will be added before the official release. On the mobile side, the current Android release (2.2) doesn’t include WebSockets support, but with 2.3 rumored to be just around the corner, it’s a good bet that WebSockets will feature in the list of additions.
You can get an idea of how useful WebSockets can be by checking out this demo by Remy Sharp. Open two browser windows side by side and fire off a chat message from one, and watch it appear instantly in the other, without the need for any persistent connections or polling. The back end for the demo is provided by a very simple node.js server.
Despite the incomplete level of support at the moment, a lot of these new APIs are definitely picking up steam and browser adoption, so it might not be such a distant future when we can start making use of them in cross-platform applications.
Thumbnail image used under Creative Commons Attribution, courtesy of Calsidyrose.
If you want to read more from Louis, subscribe to our weekly tech geek newsletter, Tech Times.