IN THIS ARTICLE
Subscribe to Our Newsletter
Smacktive is a social discovery app with a mission to create new, meaningful friendships while playing sports, exercising, playing table games with people near you. With a slick interface and easy-to-understand user experience, Smacktive launched October 8 in New York City and has already started to consider how to scale. To power this scaling, they are using PubNub behind the scenes to manage the realtime data streams of their installed user base.
Building Scalable and Reliable Android and iOS Chat
Peer-to-peer social discovery and communication is a difficult problem that iOS and Android developers have to address as their app becomes more and more popular. With n unique users, your peer-to-peer messaging system has to deal with O(n2) total data stream pathways from each user to any other user. By building your chat system on top of PubNub’s publish/subscribe architecture, you can leverage PubNub’s global platform with 15 redundant data centers to ensure that each message is delivered as fast as possible. As your app’s installed user base grows, your O(n2) messaging issue is moved off of your hardware onto PubNub’s global cloud, eliminating points of failure in your infrastructure and increasing reliability during traffic spikes.
Harnessing PubNub for Chat
Getting started with PubNub chat in your iOS app is easy, using the PubNub iOS SDK. To publish a message, it’s as simple as:
Storing Chat History with PubNub Storage & Playback
Chat conversation history is a staple of chat applications today. Users have come to expect to see a personalized conversation history with their contacts. Unfortunately, this is a feature that a standard publish/subscribe messaging architecture doesn’t include.
Enter PubNub Storage and Playback.
Each message sent over PubNub is stored for later retrieval with Storage & Playback, and can be queried using the same PubNub SDK that powers your messaging functionality. This eliminates the need for your servers to store chat data (although you can do this, if you desire, by having your server issue periodic history calls to active channels).
Using PubNub Storage and Playback, a user of your app can open their message history, send a message to a friend, receive a message from a friend and carry on a conversation without hitting your servers at all. And with PubNub Channel Multiplexing, your user can carry on simultaneous conversations with multiple users through the same TCP socket.
Walk Me Through It
Does your app require chat functionality? See our blog post Building an iOS Group Messenger App for step-by-step instructions, an Xcode walkthrough, and sample code. It’s a quick and dirty tutorial on getting your chat application for iOS up and running fast.