So you want to chat?

Let’s face it! Browser-based chat is going the way of SMS: it won’t go soon but it has become a last resort tool when everything else just won’t do. MSN Messenger is gone, and Skype chat is only to let the other part know that you’re ready to start a call, or that your boss just got in. Gtalk doesn’t have a decent app and no one really knows how most of the people in their friends list got there. Even ICQ is struggling to leave the desktop into the app store.

On the other hand, mobile IM services abound, from whatsapp to BBM, iOS Messages, Twitter or Facebook, millenials can’t get enough of those text strings, and don’t want to consign them while sitting in their bedroom desk, but from wherever their most basic communicational instincts assault them.

So, you want to tap into those big instant messaging bucks, and you are all set with your Xcode. So far XMPP has been with SIMPLE the de facto standard for instant messaging communication, but they were created and popularized for web applications, there haven’t been enough pushing by some of the main parties, like Process-One (current owner of eJabberd, arguably the more popular Jabber implementation) that doesn’t have an open API, and have the access to the cloud implementation of eJabberd 3 restricted.

Right now if you want to implement an XMPP client on iOS -and not doing it from the scratch- your best chance is the XMPP Framework, a relatively robust, complex and poorly documented implementation, available in Github under a BSD license. Now, this -or any other- XMPP client require an XMPP server to manage the chat sessions; besides the seclusive eJabberd 3, there are no reliable (or known) cloud implementations of XMPP servers on the cloud, so if you want your users to chat from your iOS app, you also need to install and maintain your own server or pay someone to do it for you, eJabberd 2, your most probably choice, is a robust, easy-to-install, open source server, that you can install in your favorite Linux implementation.

Enter the aaS

But, if chatting is just a complementary part of your app, and you want to avoid the hassle and reduce developing hours in non-critical features of your product, or even if it’s in fact a key feature, I’m glad to tell you that you have options.

Cloud-based messaging services provide messaging and cache that can easily provide the required backend for your chat application. Among them Iron.io and PubNub are prominent. Both provide messaging and chache services, with push functionalities.

Iron.io doesn’t currently have a iOS SDK, so you must connect their REST services using http requests, this means that the token remains visible, something that the technical support team strongly advise against it, instead they recommend to use a server to do the credentialing with the Iron.io servers and receiving the requests from the app. Messages are sent and stored until delivered using IronMQ or cached using IronCache, two independent services, therefore if you want your message delivered and stored you will need two http requests to two different services.

PubNub provides a single configurable service, messages can be sent, delivered and stored for short periods of time using a single service, though different features may mean different pricing. Their main services are discriminated into three different categories depending on different approaches, e.g. Pulse is based on dedicated 24/7 unicast connections and measures unique devices daily while Galaxy is based on 1-to-many broadcasts and measures daily peak connections in 1-hour slots. You can use a combination of both in your app and the differences largely disappear when you’re deployed in the global cloud. Thus, the former is ideal for private chat rooms and the latter for public rooms. A single API adresses all the services and features, and there are a myriad of SDK’s including iOS, Android and Windows Phone.

Text, Bytes and Video

However video chat is still king in the browsers, Microsoft bought Skype with the intention of convincing users of using it as a always-on chat Windows 8 app and integrate it to Outlook.com, google hang-outs are still a desktop computer thing -even though it’s moving quickly to tablets- and Facetime works in Macbooks as well as an iPhones and iPads. But change is on the way, a simple search in the Apple App Store in your iPhone will produce a long list of video chat services most of them free. So, why would your killer app must go video-less?

Here you can go several ways: you can go peer-to-peer with WebRTC or expensive but robust like SpiritDSP, there are also cloud based options like Tokbox. I really like WebRTC as a reliable open source peer-to-peer video chat libraries, but most of the iOS and Android implementations are fan fiction that can be found in someone github’s not in the official WebRTC site (yet). SpiritDSP it’s a full stack of messaging but as you will see in their long list of big corporate clients you’d probably need to charge $99.99 in the app store. Tokbox is a WebRTC based cloud service (WebRTCaaS if you may) with plenty of features like archiving and moderation. The API is very intuitive, extensively documented and supported by fellow developers.

Chat long and prosper!!!