CodeIgniter iPhone Push Notifications

by leon on July 31, 2009

200x200

I have written a wrapper in CodeIgniter for the Prowl PHP API. It allows you to easily send Push Notifications to an iPhone by calling a simple function.

Prowl is a Growl client for the iPhone. Notifications from your Mac or Windows computer (see the FAQ) can be sent to your iPhone over push, with a full range of customization and grace you expect. Prowl also features an extensive API, which allows your scripts to integrate beautifully. The API has a PHP version that allows you to integrate this with your web apps.

There are two functions and they behave slightly differently;

sendPushNotificationSingle($pushEvent, $pushDescription,$pushPriority);

sendPushNotificationMultiple($pushEvent, $pushDescription,$pushPriority,$deviceKey)

The Single function is designed to use a single device(api) key so therefore will only send to one device. The function picks up the device api from the config file. I use this when I want to be instantly alerted that something has happened on one of my sites.

The Multiple function takes the device key via a parameter in the function call. This can be useful when used in a loop (the keys can be pulled from a database).

The various parameters sent to the functions are outlined below. The values within the square brackets indicate the length of the value:

add (POST)

Add a notification for a particular user.

Parameters:

  • apikey [40]

    The user’s API key. A 40-byte hexadecimal string.

  • providerkey [40] (Optional)

    Your provider API key. Only necessary if you have been whitelisted (see API limits).

  • priority

    An integer value ranging [-2, 2]: Very Low, Moderate, Normal, High, Emergency.

  • application [256]

    The name of your application or the application generating the event.

  • event [1024]

    The name of the event or subject of the event.

  • description [10000]

    A description of the event, generally terse.

One of event or description must be provided. Priority defaults to 0 if not specified.

verify (GET)

Verify an API key is valid.

Parameters:

  • apikey [40]

    The user’s API key. A 40-byte hexadecimal string.

  • providerkey [40] (Optional)

    Your provider API key. Only necessary if you have been whitelisted (see API limits).

    Download

    The download contains a library which is the existing PHP version of the API, a helper which contains the two functions that I have created and a config file that contains various settings. Have a play around with the scripts and let me know how you find them.

    I’m not going to go into any detail about how to set up CodeIgniter – but if you are stuck, add a comment or view this brilliant tutorial.

    Download

One comment

It looks like you are a true professional. Did ya study about the topic? hehe

by kabTierie on November 27, 2009 at 9:44 am. Reply #

Leave your comment

Required.

Required. Not published.

If you have one.