For our December FAQs, we discuss one of the most popular topics of the month, mobile push notifications. In this month’s episode, Stephen and I go in-depth on:
We’ve also written a couple of tutorials around APNS, GCM, and PubNub that will get you started nice and quick.
Mobile Push Notification Gateways, APNS, GCM, and Data Streams Explained (December FAQs) from PubNub on Vimeo.
With PubNub, we send and receive messages over channels (ie. “topics”), and that gives you lots of different options on the wide variety of mobile gateways in addition to PubNub’s Data Stream Network. The PubNub mobile gateway connects directly to Google, Apple, and Microsoft for GCM, APNS, and Windows notifications.
By subscribing to a PubNub channel, all you have to do is issue a subscribe call on the channel you want to connect to. If you want to receive push notifications via the APNS gateway, you use a device registry function that’s available with the iOS SDK. With GCM, you have the Android SDK.
Data is received differently based on the state of the application or where the user is sitting on the app. For example, if you were to register on an APNS channel on Apple’s network, but if we also subscribe to a PubNub channel, we’ll receive the data on both of the networks depending on the state of the application. If we’re in the application and we’re live, the user will receive the data via PubNub, in real time. However, when the app is in the background, it’ll arrive when APNS sends it (Apple provides no guarantees).
With a single API method, we can broadcast across a wide variety of notification networks simultaneously. You can do this by defining specific keys in your payload, and in the payload, you would identify the Apple key, the GCM key, or the Windows gateway key. In that object, you paste the information that Apple is expecting to receive based on their standard docs.
Within each specific gateway, there are certain restrictions with data lengths. The entire message can be up to 32kb on PubNub, while APNS is 2kb, and GCM/Windows is 4kb.
Got some questions of your own? We’re here for you! Reach out to help@pubnub.com, visit PubNub Support or tweet us @PubNub.
We also have PubNub Office Hours at our San Francisco HQ, every Wednesday from 2-5pm, where you can get your real-time questions answered in real time. Give us a heads up at office-hours@pubnub.com and let us know you’re coming.