Bidirectional Push Notifications for Large Message Payloads
Push notifications enable you to send updates, alerts, and new content to mobile devices even if that mobile device is offline. However, when building a mobile push notification system for your application, unfortunately (for development's sake), there’s not one universal smartphone with a universal operating system. Users have a wide variety of devices running on a wide variety of operating systems in a wide variety of environments. As a result, developers need a more powerful way to utilize notification services across every mobile device.
In this blog post, we’ll give you a tutorial on using both APNS for iOS devices and GCM for Android, as well as how to integrate PubNub Data Streams for mobile push notifications. Each option has its own set of full documentation, so I’ll link you to the relevant documentation for each one after a brief overview. There are solid use cases for each push notification service, and we’ll go through the benefits and limitations of each as well.
- Delivery to any mobile device (including Android and iOS) using standard PubNub Publish/Subscribe APIs.
- Delivery to iOS devices via Apple Push Notification service.
- Delivery to Android devices via Google Cloud Messaging service.
Let’s get to it!
Google Cloud Messaging (GCM) for Android
Last month, we announced that PubNub now supports GCM, enabling you to easily build GCM/Android push notifications into your PubNub application, streamlining cross platform message delivery, and eliminating the need to develop additional server-side components for GCM.
Essentially, PubNub is the provider between devices that are subscribed to your application and 3rd party sources. GCM is a great way to deliver one-way, non-critical communications with smaller payloads (128 bytes to 4KB).
Apple Push Notification Service (APNS) for iOS
PubNub also makes it easy to deliver mobile push notifications to iOS devices including iPhones and iPads from your PubNub web or mobile application. Like GCM, APNS is one-way communication, but has a message size limit of 256 bytes per notification payload.
Check out the documentation with a full Objective-C tutorial for implementing APNS into your PubNub application. The tutorial includes an APNS architecture overview, how to set up an Apple and PubNub environment, and building and testing your APNS application.
PubNub Data Streams for Mobile Push Notifications and Bidirectional Communication
For mission critical messaging, we encourage you to check out utilizing our PubNub Data Streams publish and subscribe APIs to implement mobile push notifications. Some of the advantages PubNub Data Streams is:
- A low-latency bi-directional notification solution that can be delivered to any mobile device.
- A maximum notification payload of 32KB.
- Ability to recover missed messages with Storage & Playback.
- Secure integration with AES message encryption.
- No administrative overhead of managing devices on different 3rd-party notification services.
Despite the advantages of the native PubNub approach, there are cases where a developer may choose to utilize APNS and GCM, for example:
- Migration to PubNub messaging for existing applications already utilizing 3rd-party notification systems such as GCM or APNS.
- Apple restricts applications on iOS from running in the background and therefore iOS developers may choose to implement APNS as a means to deliver real-time notifications to an iOS device when the application is running in the background.
- Comfort level of developing in a native framework.
Mobile Push Notification Summary
As you can see, there are uses cases for each push notification service. But overall, mobile push notifications are a great way to retain user engagement, keep users in the loop, and send important updates and alerts to users in real time. It really depends on the size of the message, whether you want bidirectional or one way communication, and what device you’re sending the push notification to.