C# to iPhone push

Here I will show how to easily make a windows form application in C# and use it to send push messages to an iPhone, using Prowl.

First off, the Prowl app is only $2.99, and is only limited to 1000 messages pr. hour (Should be plenty for most, I would go crazy if my phone was vibrating/beeping anywhere near to that amount ;))

But to get started, you first need to get the app, and create an user on the Prowl website, and generate an API key. (follow the instructions on their site)

When having that sorted out, we can look at how to actually communicate with their server, and the url to do that with, looks like this

https://prowl.weks.net/publicapi/add?apikey=[api key]&application=[application]&event=[event]&description=[decription]&priority=[-2 to 2]

Like that it would be pretty easy, all we need is to make a form application, put four fields in to hold the api key, application, event and decription.

Two buttons, one to send the message, and reset to clear the application, event and decription fields.

To use the prowl priority option I chose a ComboBox to make it more easy looking.

Building the url can look something like this:

string baseUrl = "https://prowl.weks.net/publicapi/add";
baseUrl += "?apikey=" + pApikey.Text;
baseUrl += "&application=" + pApplication.Text;
baseUrl += "&event=" + pEvent.Text;
baseUrl += "&description=" + pDescription.Text;
baseUrl += "&priority=" + (pPriority.SelectedIndex - 2).ToString();

The priority is the index of the selected option (zero index), so by removing 2 it will go from -2 to 2.

And my finished application, simply put the test in, and press send.

And the message should arrive 🙂

Notice the prowl service also returns error codes if something went wrong, the amount of messages left, and when the counter will be reset, but this application does not handle any of those, yet.

  • Download example


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.