As soon as your boss gets an iPhone, he’s going to be asking you how to get to your corporate data from the road. The good side is that you’ll need to get both a Mac and an iPhone but then you need to make it all happen. We focused on delivering a solution quickly that was very simple, adjustable and quick to market.
Specifically for us, we have corporate statistics that our executives wanted to be able to view easily from the road without having to boot up a laptop, find wireless, login to our web app, navigate to the statistics page… you know the drill. Instead, they should be able to pull their iPhone out and push a ‘stats’ button. Boom! There are the stats.
Many people are searching for the golden sample iPhone application that they can mode and forget that there is back-end infrastructure required to feed that data to the requesting iPhone. To get that done, you’re probably already thinking of a nice web service feeding back XML. SOAP comes to mind but the current release of the iPhone SDK is light in support. This is where most people will direct you to use REST. REST is cool in that it is a URL based requestor but it takes a lot of work to set it up.
Remember that part of our goal is ‘quick to market’ so why not consider the generic HTTP handler that is in Visual Studio.
Here’s what you do:
1. follow the sample for building an RSS reader and get it wired into your iPhone. Follow it word for word and it will work great. Here is the link: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone
2. now in Visual Studio add a public generic handler. This will be a.ASHX file
3. in your SQL database, build a table that houses a user name to iPhone ID relationship
4. edit the generic handler to take in two parameters — one for the requested operation (in our case: stats) and one for the iPhone ID.
5. if they are validated respond to them with the stats in XML using context.response
6. test this in your browser passing the correct parameters so you know it’s working before you start trying to hit it from the iPhone.
7. now adjust your iPhone app to use your new URL with parameters.
Once you get the basics working:
1. create a corporate DB table that houses iPhone ID to user Id relationships and check it as the first operation on the handler. This makes the handler extremely secure because you can’t get past the front door without a valid iPhone Id. BTW, we used UDID to get the addresses to be used. You have to do this for the ad-hoc provisioning anyway so you’re doubly covered.
2. create a logging function that writes the date, time, user,iPhone and function to a table
3. enhance the iPhone app to allow drill-down capabilities (just another operation)
A couple of notes:
-this is scalable by way of the parameters passed.
-you can adjust the output at the asp.net level instead of the iPhone.
-this is very secure in that only the registered iPhones will get in.