Senior Content Strategist, PubNub
IN THIS ARTICLE

    Push notifications enable you to send updates, alerts and new content to mobile devices even if that mobile device is offline. However, when it comes to building a push notification system for your application, unfortunately (for development sake), there’s not one universal smart phone 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 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.

    We’ll cover:

    • 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

    push notificationLast 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).

    Below is the documentation with full Java and JavaScript tutorials for implementing GCM. Each tutorial walks you through the architectural components, SDK methods, and how to send and receive GCM push notifications.

    Apple Push Notification Service (APNS) for iOS

    push notificationPubNub also makes it easy to deliver 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.

    If you prefer video over text, we have a eight video series on setting up APNS with Apple, then setting up APNS with PubNub.

    PubNub Data Streams for 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 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 realtime notifications to an iOS device when the application is running in the background.
    • Comfort level of developing in a native framework.

    To get started with PubNub Data Streams for push notifications, check out our JavaScript Mobile Push Gateway or Java Mobile Push Gateway documentation.

    Push Notification Summary

    As you can see, there are uses cases for each push notification service. But overall, push notifications are a great way to retain user engagement, keep users in the loop, and send important updates and alerts to users in realtime. 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.

    Try PubNub today!

    Build realtime applications that perform reliably and securely, at global scale.
    Try Our APIs
    Try PubNub today!
    More From PubNub