The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.


UPDATE (8/31/11) – this functionality is now delivered as part of the Mobile SDK Developer Preview – check it out at!

This is part three of a three part series showing how to call the 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

Watching Quinton and Mike‘s webinar on Building Mobile 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 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 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.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS