What is push and why is it important?

People used to access a browser for information, but now they download an application and expect it to send them information when they need it. With push notifications, the application can still talk to people when the application is closed. Users are also more responsive to push notifications as compared with email or text messages (source). Push notifications are not only a useful way to communicate with users– they can be used to save battery life because information can be passed directly to the phone rather than the phone constantly polling for data.

Before you begin

You will need the following to add push notification functionality to your app:

  • Mobile Application (Native iOS, Native Android, Phonegap, etc…)
  • An Application Server (Server that holds your app’s data and sends pushes)
    • Database (Stores user data and push tokens)

We assume you have already planned for the following:

  • Plan to handle risk management and disaster recovery
  • Business understands push notifications do not have a feedback service

How push works

At a high level, sending a notification looks something like this:

All pushes go through a push notification provider, which is determined by the operating system of the push you’re trying to send to. Apple’s iOS uses a service called Apple Push Notification Service (APNS) and Google’s Android uses one called Google Cloud Messaging (GCM, formerly known as C2DM). Windows Phone uses Microsoft Push Notification Service (MPNS). The push originates from your application server, which sends the message with an identifier to the push provider that relays the push to the desired device.

Registering with the push notification service (Apple, Google, etc)

You will need to register your application with the push notification service to send pushes to your application on a device. When your application server sends a push to the push notification service, you will use the credentials that you got from this step.

Registering the device for push (get token)

In your application, you need to request a token from the push notification service. This token represents your application running on a specific device, and when your application server wants to send a push to that device, it will use this token. At a high-level, registering looks very similar to the following diagram:

Sending the token to the application server

When you receive a token from a push service, you need to send this token to your application server so that you can send messages using the token. If you are using Urban Airship or another push provider, you will need to send this token both to Urban Airship and your own server, as shown by the following diagram:

How to send a push from the application server

Your application server will need to make a call to the push notification service using the service’s API. If you’re using Urban Airship, your application will send to the push there, and Urban Airship will then forward that information to the push notification service.

How to handle a push on the device

Pushes are sent to the device and then the operating system will pass that information onto the application. It is the developer’s responsibility to determine what will happen when the push is received. Apple and Google have some major differences at this point, which will be explained in their respective pages. There are three general use cases that can occur:

The app is closed

The developer will need to determine what will happen when the application is in the background or hasn’t been started.

The app is open and in the right context

Sometimes the application is already open on a certain screen and new information comes in related to that screen (on Facebook a new status is posted or in a chat application the friend you’re chatting with has sent a new message). In these cases, rather than showing a new alert or status bar notification, the page should have some sort of “refresh” method.

The app is open and in the wrong context

Sometimes the application is open to a certain page and new information comes in not related to that page (on Facebook you’re invited to attend an event while you are looking through a friend’s photo album or in a chat application you’re chatting with a friend and another friend sends you a message). In these cases, you may want to show a new alert or status bar notification, or you may want to display some sort of in-app notification.

Where to go from here

We created a push notification framework for incorporating push notifications in Native AndroidNative iOSPhonegap iOS and AndroidRhodes, and Unity platforms. We selected Urban Airship from a list of push providers. We also created an application server from which to send these notifications. Each application section includes general information for where to begin when creating an application and general tips and tricks we found through our development.

One thought on “Overview

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s