How to Push Notifications to Your Android With Pushover

The Android notification bar is one of my favourite aspects of the OS – and I’m certainly not alone. Even iPhone fans succumbed to its lure when Apple introduced an identical feature with iOS 5.

It’s underutilised to say the least, with most notifications coming either from the phone itself or third-party apps letting you know who just tweeted you. Imagine if your website, computer, servers, desktop apps or pretty much anything else could send you important messages, updates and alerts straight to your Android.

That’s the idea behind Pushover: push messages, straight to your phone. Here’s how to get the most out of it.

How It Works

Notifications with Pushover

Notifications with Pushover

A push transmission, put simply, is when a message is forced to transmit at the time of sending. This is opposed to a ‘pull’ which requires a user to go get it from the server. For example, if you’re notified when someone tweets you then that’s a push notification. If you have to refresh from within the app then you’re ‘pulling’ in the notification.

Pushover works by receiving a notification on their servers from a program running on our computer or server, and then forcing that notification to appear on your Android device.

This is done via HTTP as basic text notifications. If your phone is connected to the Internet then it will instantly receive the notification from the Pushover servers. If not, it will remain there for 30 days until you do connect.

Your notifications are secure, as all transmissions are encrypted.

But how do the Pushover servers recieve notifications to send to an Android phone? Well, using basic code or third-party plugins, you can tell programs on your computer or website to notify you if certain things happen. For example, you could tell your web server to notify you when it’s near capacity, or instruct an open-source torrent downloader to notify you when a download is complete.

The possibilities are complex and endless, with just about anything you like having the ability to be flagged for notification.

Basic ‘Human’ Notifications

In its most basic form, Pushover allows you to set up an unlimited number of phones and send them all text notifications from the Pushover website. It’s a little archaic but could definitely be put to good use by organisations or groups. It’s really simple too.

First, download and install the Pushover app on your phone. Then go to Pushover.net and create an account (can be done from the app too).

Using the application, enter in a unique ID for your phone. This will attach that phone to the Pushover account enabling any transmission through that account (manual or otherwise) to be sent over HTTP to the phone.

Send notifications to any enabled devices

Send notifications to any enabled devices

To transmit a notification to either a single phone or a group, simply sign into the Pushover website and fill in the message fields. Provided the phones are connected to the Internet, they should receive your notification within five seconds.

Third-Party Applications

As Pushover is a new service there are not a lot of apps and websites that currently work with it. However, a few independent developers and sites have made notifications plugins for things such as IMs, battery levels of gadgets and server monitors. You can check them out here.

Integrating with Your Sites and Apps

This is where the true power of Pushover comes into play: giving you notifications about things that matter to you. For example, a sale on your ecommerce site, your server’s current capacity or a security alert in your home or on your website. The possibilities are endless when you consider that almost all new programs, devices and systems connect to the Internet.

Pushover’s API is inclusive of the popular programming languages Ruby, Perl, Python and PHP. Their website has code snippets which enable you to code notifications which can be sent to your device.

Here’s a sample code snippet using Ruby:

require "net/https"

url = URI.parse("https://api.pushover.net/1/messages")
req = Net::HTTP::Post.new(url.path)
req.set_form_data({
  :token => "APP_TOKEN",
  :user => "USER_KEY",
  :message => "hello world",
})
res = Net::HTTP.new(url.host, url.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
res.start {|http| http.request(req) }

For more information and coding tutorials, see Envato’s Tuts+ network.

For code snippets for other languages, see Pushover’s FAQ.

There is also support for Windows and UNIX operating systems, allowing you to insert the code snippets either into command lines or as shell scripts.

If you’re developing an app or program you’ll need to get an API key so Pushover can authenticate messages received from the app. To do this, simply register your app with them and you’ll be issued with a key. You can upload a custom logo which will appear alongside any notifications you issue.

You’ll also need to create user identifier codes and user names. These will enable Pushover to see who is on your network and enable you to select who you want to send messages to. Ideally, your app should allow users to register and automatically update the database of users, and also edit their username in the future.

The actual messages your app will send must contain at the very least a ‘message’ parameter. A ‘title’ parameter is optional – if you choose to leave it out, Pushover will display the recipient’s username by default. When a notification is required, you application should construct a POST request and send it to https://api.pushover.net/1/messages.json .

The message should contain the following:

token = J3IJDReXKyyNaC0QyomlYEEokJnyFe
 user = ee85fr5ec9fheTgf983cdh00jk876
 device = phone66
 title = Backup finished - SQL1
 message = Backup of database "example" finished in 16 minutes.

NB. The ‘token’ is your API token mentioned above.

To override a user’s ‘quiet-time’ settings in the case of an emergency (such as a security breach), include a ‘priority’ parameter and give it a value of 1.

Conclusion

The end result should be something similar to what you see below – a small message that appears at the top of the Android screen in the same manner as normal notifications.

Notification Received!

Notification Received!

Pushover is still new so there is virtually no community surrounding it. This means that, for now, a lot of the pioneering will have to be left to the more experienced among us. Overall, though, I think it shows great promise thanks to its relative simplicity and prospective uses with individuals and organisations.


  • hellzou

    Super ça ! Je vais inclure ça dans certains de mes scripts shell ^^

    • hellzou

      A bit expensive by the way..

    • http://www.twitter.com/deansherwin Dean Sherwin

      Qui, je recommende cette action. Le app est trés bon quand travaille avec d’autres app et soft.

      Il apporte vouz portable et vouz ordinateur rapproacher.

      Je suis désole pour mon francias mais cest l’maixmale de mon capacité au mon bác.

      Merci pour vouz message.

      - Dean.

      • hellzou

        Haha, I’m sorry. I’ve totally forgotten I was on an english written website. i don’t know why :P

        Thanks for the effort in french ^^

  • http://AndroidTipGuys.com/ Tim Lenahan

    Pushover looks like a really great idea. I hope some WordPress developers jump on the bandwagon and make some nice plugins, etc., for the less experienced webmasters to use.

    I too love the notifications bar in the Android OS. Using the free app Notifier, you can also send custom reminders to the notifications bar. Love it!

    • http://www.twitter.com Dean Sherwin

      I too am hoping that’s going to happen.

      The fact that it can be integrated with so many different types of code makes this a real possibility. Imagine getting notifications every time your blog got a comment, you made a sale on your Shopify site or your company was mentioned via Google alerts!

      Cheers,
      Dean.

  • eng_dev

    is there push notification for android device using corona sdk ??

  • Akshay

    Now i get idea about push notifications, thanks a lot.

theatre-aglow
theatre-aglow
theatre-aglow
theatre-aglow