Pushy - An Alternative to Google Cloud Messaging
Jan 10, 2015
After writing the post about my letdowns with Google Cloud Messaging, I set out to find an alternative way to send push notifications reliably on Android.
I stumbled upon numerous SaaS push notification services, such as OneSignal, Parse, Boxcar.io, UrbanAirship, PubNub, and AWS SNS. Unfortunately, I discovered that all of these services piggyback on GCM, simply making it easier to develop push notifications for iOS, Android, and Windows Phone at the same time. The apps still need to register with GCM (and fail repeatedly with SERVICE_NOT_AVAILABLE
), and the heartbeat interval will still prevent users from receiving push notifications, because the underlying socket is still handled by GCM.
I was not able to find a single push notification service that didn't depend on GCM. So I built one.
Pushy
Pushy is a standalone push notification gateway, completely independent of GCM. It maintains its own background socket connection to receive push notifications using MQTT, an extremely light-weight pub/sub protocol that requires very little network bandwidth and battery to maintain. The decision to use MQTT was confirmed after comparing multiple protocols, including WebSockets and XMPP, for their bandwidth and compute requirements. In addition, the fact that Facebook chose to implement its push notifications for Facebook Messenger using MQTT is highly convincing.
The entire Pushy backend is built with Node.js and MongoDB on top of Amazon Web Services and scales automatically to support all the concurrent devices.
Using Pushy to send notifications is very similar to using Google Cloud Messaging. Your Android app registers with Pushy and receives a device token, which it then sends to your backend server to store for later. When it's time to send a push notification, your backend server sends the device token to Pushy via a simple JSON REST API along with the push payload, and in less than 1/4 of a second, the push notification will arrive. The workflow is the same as with GCM.
Since Pushy doesn't rely on GCM or Google in any way, it's also an excellent way to deliver push notifications in China, where Google services are blocked, or to devices that lack the Google Play Services framework, such as enterprise Android phones or Amazon Kindle devices.
Drop-in Replacement for GCM
A huge advantage of Pushy is that it's a drop-in replacement for Google Cloud Messaging. The code for sending a push notification (from the server) and registering a device is almost identical between GCM and Pushy. This makes it super easy to switch to Pushy after implementing GCM and having to ditch it for its instability. Check out the migration guides to get started.
Try it out for Free
Want to give Pushy a try? Get started with a free trial account, no credit card needed.
Let me know what you think about Pushy in the comments!