Skip to content

Instantly share code, notes, and snippets.

@xhip
Last active August 29, 2015 14:16
Show Gist options
  • Save xhip/a7c4018997748b33b54b to your computer and use it in GitHub Desktop.
Save xhip/a7c4018997748b33b54b to your computer and use it in GitHub Desktop.
Prowl is a nice Growl client for iOS. One can use Prowl to send push notifications to an iOS device from essentially any computer with an internet connection.
The Prowl iOS app is inexpensive, and is available from the App Store. Sending notifications to iOS devices using Prowl is free of charge. There are, of course, alternative notification services available, including some that work with both iOS and Android devices (Prowl is iOS only as far as I am aware).
Prowl has a straightforward third-party API which allows notifications to be sent via Prowl using any modern programming language. There is an officially supported Perl script which can be easily used to send Prowl notifications from an internet connected Raspberry Pi. There are also a couple of third-party Python scripts available from the Prowl website which could alternatively be used.
In this post I’ve used the officially supported Prowl Perl script to show how one can send notifications to iOS devices from a Raspberry Pi running the standard Raspbian linux operating system.
Here’s how to install the Prowl Perl script on your Raspberry Pi:
1) Firstly, you’ll need to go to the Prowl website and create a free account. Once you’ve done that, you can go to the API Keys section of the Prowl website to create an “API key” that you’ll need to provide to the Perl script. You can create as many different API keys as you need, and each one can be given a label so it’s easy to keep track of what you’re using each of the API keys for.
2) Next, download the Prowl Perl script to your Raspberry Pi:
wget http://www.prowlapp.com/static/prowl.pl
3) The Prowl Perl script has some Perl library dependencies, which will need to be installed on your Raspberry Pi in order for the Perl script to run. You can easily install the necessary libraries as follows:
sudo apt-get install libwww-perl
4) The Prowl Perl script can be run from the command line, and you can just supply the API Key as one of the command line arguments to the script.
Type:
./prowl.pl
to see a list of command line options for the Prowl Perl script.
An alternative to supplying the API Key to the Prowl Perl script on the command line each time the script is run, is to put the API Key into a file, and then pass the name of this file to the script instead. To do this, just copy and paste the API Key from the Prowl API Keys webpage into a text file on the Raspberry Pi. The API Key text file can take any reasonable name you like. You might wish to restrict who can read this API Key file on your Raspberry Pi. You can limit the read permissions for the API Key file to yourself as follows, where in this example the API Key text has been pasted into a file called “prowl_key.txt”:
chmod 600 prowl_key.txt
5) Once you’ve installed the Prowl app on your iOS device, you’ll need to start the app and login to your Prowl account. Once you’ve successfully logged into the Prowl iOS app, you’re ready to start sending notifications to your iOS device from your Raspberry Pi! Note that the Prowl app does not need to be running on your iOS in order for you to receive Prowl notifications. You can control how Prowl notifications are handled on your iOS device by using the “Notification Center” settings within the iOS Settings app.
Send a test notification from your Raspberry Pi as follows:
./prowl.pl -apikeyfile=prowl_key.txt -event="Test" -notification="Hello from RasPi"
If this is successful you should, after a short delay, see a “Notification successfully posted.” message on the Raspberry Pi console, and a little while after that the push notification should appear on your iOS device! Note that if you have multiple iOS devices, each with the Prowl app installed and logged into the same Prowl account, then any Prowl notification will be received on all of these iOS devices.
You’ll notice from the prowl.pl command line options that a Prowl notification can contain a URL, as well as plain text, and this could be used to direct the notification recipient to additional resources e.g. data recently uploaded to a Dropbox account by the Raspberry Pi.
There are obviously many possible uses for this kind of notification service, but one downside, of the Prowl service at least, is that there’s no way to send a return message to the Raspberry Pi from the receiving iOS device.
For two way communication between a mobile device (iOS or otherwise) and an internet connected Raspberry Pi, I’m thinking of using email, as it’s possible to access a gmail account and parse email messages using Python, on a Raspberry Pi. Using email messages in this way would obviate the need to expose the Raspberry Pi to the wider internet outside my router’s firewall.
( from: https://minordiscoveries.wordpress.com/2014/01/04/sending-prowl-notifications-to-an-ios-device-from-a-raspberry-pi/ )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment