Closest thing I've found is How to incorporate WebSockets into a Cocoa application, but the answers only pointed to an outdated library.
Does anyone know about a WebSockets library compatible with iOS 4.x?
I've also read about Pusherapp, and, as good as the service could be, I would prefer to use my own WebSockets server.
As you can see from the code snippets above, although the communication is done over WebSockets, the underlying WebSocket protocol is ''hidden'' from developers. You can decide to use any WebSocket-based protocol that supports iOS.
WebSocket is a communication protocol that uses sockets, providing duplex communication over a single TCP connection. It was standardized by the IETF in 2011 and is a different protocol from HTTP. WebSockets are widely used in chat apps, streaming real-time notifications, and stock prices.
NSURLSessionWebSocketTask is a concrete subclass of NSURLSessionTask that provides a message-oriented transport protocol over TCP and TLS in the form of WebSocket framing. It follows the WebSocket Protocol defined in RFC 6455. You create a NSURLSessionWebSocketTask with either a ws: or wss: URL.
The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
You can check out the UnitT Web Socket Client. It is intended for use in iOS apps using Objective-C. It works with both ws & wss.
I am the author and have been using it in some of my projects with success. Let me know if you run into any trouble and I will do what I can to help.
Found this post in a google search for iOS WebSockets and wanted to put an updated answer.
Anyways, Zimt and Unitt's client don't support the latest standard (at the time of writing this).
(disclaimer: author of SocketRocket)
We just released a new library that has no external dependencies, supports RFC 6455 completely, and works with iOS 4.x+.
It's called SocketRocket and can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With