Xcode

UPDATE (8/31/11) – this functionality is now delivered as part of the Mobile SDK Developer Preview – check it out at http://developer.force.com/mobilesdk!

This is part three of a three part series showing how to call the Force.com REST API from JavaScript in various scenarios. Part one, Calling the REST API from JavaScript in Visualforce Pages, explained how to call the REST API from JavaScript in the context of a Visualforce Page, while part two, Calling the REST API from JavaScript… from Anywhere!, showed how to call the REST API from JavaScript served from a domain outside Force.com.

Watching Quinton and Mike‘s webinar on Building Mobile Force.com Apps for the iPhone and iPad, I was inspired to spend a couple of hours yesterday looking at PhoneGap, a framework that allows you to author native apps using web technologies such as HTML5 and JavaScript. In particular, I was interested to see if I could package the jQuery Mobile app I wrote to show how to use the Force.com REST API from JavaScript as a native iPhone application. With the help of a wiki entry on the PhoneGap website, I was able to get something working pretty quickly, extending the JavaScript REST toolkit to access the REST API directly (rather than via a proxy) if it’s running on PhoneGap.

As usual, you can find the code in the GitHub project – see the README and phonegap.html. If you want to get something running yourself in PhoneGap, you will need to rename that file to index.html (it turns out that the StartUrl property in PhoneGap.plist I mentioned in the original version of this post is not supported in PhoneGap 0.9.5). If you’re new to PhoneGap, it’s probably best to get the ‘Hello World’ app working before you try calling the Force.com APIs – it took me a little while to assemble all the parts (there is some tweaking required to get PhoneGap working with Xcode 4, for example). Once you have something basic working, you’ll need to include the ChildBrowser PhoneGap plugin in your project as well as all the jQuery-related JavaScript files.

tagged , Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • http://profile.typepad.com/andrecharland AndreCharland

    Hey Pat!
    Love what you’re doing here! Please send us any feedback you have on PhoneGap and working with it. I’d also love to chat about the potential of working together on a PhoneGap Plugin for SalesForce to make this sort of work easier for devs!

  • http://blog.superpat.com/ Pat Patterson

    Hi Andre – drop me an email – ppatterson at salesforce dot com.

  • http://www.tgerm.com Abhinav Gupta

    Interesting post Pat, it will save me from hosting something on App Engine, just to tunnel salesforce web service calls. Javascript is becoming language next for sure :)

  • Pingback: Microsoft's Skype approval may be inching closer (and more news from around the Web) | ZDNet