By combining the Parse API with PubNub Data Streams you can obtain the ultimate developer toolkit powerful enough to scale your successful mobile app to billions of users. Using the Parse API for user management with large file storage and PubNub for data streams, you can power live user communication to your app supporting both iOS and Android.
In this tutorial, we’ll cover the common goals to build a modern user collaboration and communication app. You can enable your users to share files or store documents while communicating via chat messaging cross device on iOS and Android. You’ll be ensured the technology selection offers easy and automatically scaling technologies with high reliability.
The Parse API and PubNub provides you with a scaling infrastructure and enables you to take advantage of pay-as-you-grow cloud based pricing model. Essentially your toolset is providing you the time boost you need to build your chat and multi-user communications apps on a bootstrap budget. You’ll be using Parse Cloud Code and iOS Objective-C SDK toolkits for this walkthrough.
In this walkthrough, you will be creating the beginnings of understanding the code parts to get started with Parse API and PubNub Objective-C WebSocket SDK for iOS. You are likely going to need an authority system with a real-time messaging for chat in combination with Facebook/Twitter/Google authentication.
We won’t cover third party authentication in this guided tutorial, however you will learn the important starting point which will make your integration with authentication simpler.
For example, you may be building collaborative document storage and sharing into your app. Regardless of the features you are building by combining the two cloud platforms, you will need to know a universal ground of truth to work from.
Parse takes care of core user management features and basic file storage while PubNub provides Data Stream Network for delivery of real-time messages such as long-held HTTP Streaming connection, HTTP Long-Polling, XMPP, BOSH, Comet and WebSockets with Push Notifications for backgrounded or closed apps.
When you combine Parse API and PubNub, you can create user interactivity in real time like chat, document and photo sharing while using these platforms as your toolset. You will need these systems to auto scale to millions of users, if needed, and deployable quickly and iteratively.
Of course you will need quick deployment accessible for two or more developers and a very high reliability platform that can grow in compute capacity to millions of users automatically. You’ll need to support your app’s business needs using Facebook/Twitter/Google login support to exchange access tokens to establish a necessary non-repudiation when communicating securely over encrypted communication channels.
PubNub – Real-time Message Delivery & Mobile Push Notifications like APN
Parse API – Shared file & image storage
Parse + PubNub Publish Messages: Publishing messages from Parse.com Cloud Code via PubNub
You can publish messages inside of parse cloud to your mobile users to create chat experiences easily. If you want to send the messages directly from within Parse Cloud, use the following code to send a message to a user. You can achieve this by using Parse HTTP Requests.
Cloud Code allows sending HTTP requests to any HTTP Server using
Parse.Cloud.httpRequest. This function takes an options object to configure the call. There is a limit of 2 concurrent httpRequests, and additional requests will be queued up.
You don’t necessarily need to use Parse API this way but it is important to show you how to send notifications from Parse directly when you have certain type of notifications you must send quickly to your end-users.
A faster way to send messages between users is possible. Using the faster option is preferred. You should instead send messages directly between users to each user’s channel name using Objective-c. You will want to also add Access Manager for access control however we will not cover this topic in this tutorial. Let me show you how! Sally has
"channel-sally", and Bob has
"channel-bob". You can publish and subscribe directly form your Objective-C App Code. Bob will subscribe to his own channel and a Sally to her channel.
Bob can receive messages on his own channel and he can send messages to directly Sally or any other of his friends.
Note that rather than using
"channel-sally" as the channel names, we recommend you use
"USERID" style channel naming schema.
One common question you will have is “How can i assign a user to a channel?” So instead of using Bob’s channel as
"channel-bob" instead you will create a
USERID for Bob using Parse API. Essentially you will be assigning the user’s channel by getting the
USERID from Parse API
"PFUser" and use the
USERID as the channel name. Use
"PFUser" to identify Bob’s channel: