Python shell script / library for Notifo

iPhone notifications from the command line


Demo of Notifo
Example of an iPhone notification when a new order is received.

Examples

When in subscribe_user mode, a list of Notifo usernames is read, and one call is made to try to subscribe each.

When in send_notification mode, the program reads from stdin until EOF and uses this as the message body. The title, URI, and a list of recipient usernames can be specified on the command line.


Background

Notifo is a web service which lets you push notifications to a mobile device. As of 4/23/2010, an iPhone client is available, and Android and Blackbery are said to be coming soon.

When a user has the iPhone client installed, and a notification is pushed to them, they will typically receive the message within 15 seconds or so if they have network connectivity either via WiFi or cellular data.

This script lets you push notifications to your Notifo subscribers (including yourself) from the command line, and as such may be particularly useful from cron jobs, etc. It also serves as a Python library for interfacing with Notifo.


Quick start

  1. Get a Notifo service provider account.
    Per this blog post, a user account may also work fine (though it won't support subscribe_user calls, and you can only send to yourself).

    You'll also want to get a Notifo user account and install the iPhone client.

  2. Download it.
    Right click to save: Download the script, or:
    wget http://www.nerdkits.com/files/notifo/notifo-0.1.py

  3. Rename it.
    If you want it to work as notifo from the command line, then:
    mv notifo-0.1.py notifo
    Placing it into a directory in your path, such as ~/bin/ (if enabled), may be useful. If you want to use it as a Python library, then make sure you call it notifo.py.

  4. Mark as executable.
    chmod a+x notifo

  5. Edit the file with your Notifo service provider authentication info.
    Near the top of the file, you'll see two lines:
    NOTIFO_USER = 'YOUR_NOTIFO_USERNAME_HERE'
    NOTIFO_KEY = 'YOUR_NOTIFO_API_KEY_GOES_HERE'

    Put your Notifo username and API key (not the same as your password!) between the quotes, and save.

  6. Try it.
    ./notifo --subscribe_user your_notifo_username*
    echo "Hello world" | ./notifo --title "First test" your_notifo_username

    * This will fail (error 1101: Invalid Credentials) if you've used a user account API key instead of a service provider API key. But that's OK -- you can still send a message to yourself.


Requirements


See also


Learn electronics and programming with NerdKits microcontroller kits.