1. Code
  2. Push Notifications

Generate Notifications From Your Web App With the Pushover API

Final product image
What You'll Be Creating

Pushover is one of my favorite services over the past few years; it makes it easy and inexpensive for developers to send push notifications to iOS and Android devices without having to develop their own application. 

It also recently added desktop browser notifications as well. The service is largely free for low level usage and the apps only require a $4.99 fee after a five-day free trial; there is no monthly fee. Working with its API is straightforward and there are libraries available for a handful of different languages.

While a number of front-end app developers integrate with Pushover, e.g. IT, I find it most useful as a developer for receiving notifications related to my own applications and web servers. For example, I've integrated Pushover into my Simple Monitoring application to alert me to website failures as well as sending twice daily heartbeat notifications when nothing is wrong. If MySQL fails or my DNS goes down, I'll receive a speedy alert to my iPhone. 

Similarly, I integrated Pushover into SimplifyEmail to send notifications when emails with specific keywords arrive such as "urgent" or from specific senders such as "Tom McFarlin" (Envato's Code editor).

Here's what Pushover alerts look like on your phone:

Sample heartbeat and failure alerts from Simple Monitor using Pushover

Pushover offers a variety of sounds to customize notifications and it also supports user-configurable quiet hours, so you don't have to be woken up in the middle of the night unless you want to be:

Configure Quiet Hours within Pushover

Just remember, real SysAdmins don't sleep!

Getting Started With Pushover

To get started with Pushover, visit the website and sign up:

Sign Up for Pushover

Then, install either mobile application or the desktop browser notification support. Each offers five days of free usage before you'll be required to purchase each for $4.99. For the iOS and Android apps, you can just download them from the app stores.

Install Pushover for iOS

When you install the mobile app, it will ask you to log in and specify a device name of your choosing, e.g. iPhone.

Setting up the desktop browser-based notifications is a bit different. Visit the Pushover for Desktop page and choose a simple name for your Pushover browser notifications:

Choose Your Desktop Notification Device Name

Instruct your browser to allow notifications:

Then, you'll see the Pushover desktop in-browser app:

The Pushover Browser-based App

Ultimately, desktop notifications from Pushover will look like this:

Example of a Pushover Web Notification

Once you have installed Pushover on your device and web browsers, you can begin sending test notifications from the Pushover website:


But the fun is just beginning—let's get started using the Pushover API.

Developing With the Pushover API

Pushover requires that you register each application. Just visit your apps page:

The Pushover Apps Page

 And register a new application:

Create a New Pushover Application

You'll be given an API token to use to send notifications from your application:

An API Token for Pushover Apps

The Pushover home page offers some simple examples of sending notifications with curl:

But, for Simple Monitor and Simplify Email, I use Chris Schalenborgh's PHP Pushover library. For example, in SimpleMonitor, I use a background CronController that runs all of the tests the end user configures through the web user interface: 

Here's an example of Simple Monitor's list of my checks which trigger different Pushover notification sounds:

Using Pushover Sounds with Simple Monitor

My TestAll method, called by cron, processes each of the user-configured tests. If there is a failure, it notifies each registered device. If there is no failure, it determines whether it's time to resend a heartbeat notification, letting me know the monitor is still up and running:

My Notify method is what actually calls the Pushover PHP library to send the notifications. This is what you might use in your own application:

As a developer, I've found Pushover to be tremendously useful for delivering notifications in the absence of a dedicated mobile application. To me, Pushover's mobile app is like a SysAdmin dashboard that I didn't have to build. But it's also great for sending notifications for important emails or other server events. It's also fun to prank your friends if you can get hold of their user tokens and device names; but I would never do that.


I hope you enjoy using Pushover as much as I have. If you'd like to explore alternative services to Pushover, check out Boxcar and Panacea. I'd love to hear your thoughts. 

Please post any comments, corrections, or additional ideas below. You can browse my other Tuts+ tutorials on my author page or follow me on Twitter @reifman.

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.