Posts Tagged 'MySQL'

Of Nick and the APNS…

So on Sunday I got the inspiration for my second iPhone app, fmNotify. (the first was a simple multi-tab webkit integration for a friends website that made use of some clever code to hide the tab and status bars when rotated as well as the shake gesture to go back on the current page)

fmNotify will be (ok I’m being a tad presumptuous but I have faith :>) our internal notification service for emergency alerts. It utilizes Apple’s fantastic push notification service (APNS, APN or APS depending where you read it) and some clever UI to streamline alert handling. Basically alerts and phone registration is handled by PHP code running on a server(s, easily redundant using mySQL replication) inside our network, stored in an SQL database. This allows for  pretty extensible triggering of alerts, everything from Nagios, email via procmail, and our own internally developed software.

The real thing I wanted to talk about is how impressed I am in the APNS bits of the SDK. iPhone SDK 3.x is really where the iPhone hit its stride, and the push SDK is a big part of that. (Prior to 3.x it was a pretty disappointing device IMO and more than a fancy toy for teenagers than anything workable.) OS 3.x makes the device a powerful device for any industry. (Though MobileMail.app is still so woefully inferior to the Blackberry)

BUT I DIGRESS. Working with APNS is a coders dream. When your app is setup with Apple for push support, you get a cert that can be used to connect to the APNS cloud with. APNS requires a connection via TLS or SSL, which of course can be done easily with libopenssl in C or in this case PHP. From there all you need to do is send json blobs that contain: the device id of the handset, the alert text you want to display, the badge number to show on the app (if desired) and the sound to play (if desired). Beyond that you can include whatever other custom data you want, within 256bytes. This may seem like a rather limited amount of data to work with, but its really just to trigger your app to connect to you own servers, which can then pull down whatever data you want.

So while your app isn’t running and a notification comes in, a popup will occur with vibration/sound if desired, and a link to automatically launch your app.  While it is running an event is triggered within the app delegate and you can handle it however you want. Pretty awesome. Throw that all together with a nice GUI and you have a really streamlined alert / alert handling work flow!

So the app itself is pretty simple. Just a basic UI for seeing alerts / alert history, and then panels for dealing with common alerts.  The backend is basic PHP / mySQL / simple JSON / openssl integration to handle registration (including the device id and desired alert sound) for each phone, and directing of alerts to whoever is oncall. I really look forward to future projects using APNS, considering this took less than a day to throw together, the sky is the limit!

Recent Photos

Red List’s Species of the Day