Announcing: PhoneGap iOS Plugin for Drupal v0.1


PhoneGap iOS Plugin for Drupal v0.1 - Proof of Concept - https://github.com/jefflinwood/Drupal-Plugin-for-PhoneGap-for-iOS

While working on the Building an app with jQuery Mobile, Phonegap, and Drupal 7 series of blog posts, I found myself writing JavaScript to access the Drupal Services API, using jQuery’s $.post and $.get.

This quickly became unwieldy, so I felt like I either had to create a JavaScript library for interacting with Drupal that I could leverage in the future, or to follow the lead of the PhoneGap team and create a Drupal plugin in Objective-C that exposed Drupal Services with an easy-to-use JavaScript API. Because Kyle Browning’s Drupal iOS SDK already has code for interacting with the Drupal Services API, I decided to create a PhoneGap plugin.

Creating a PhoneGap plugin for iOS was a little trickier than I thought, mostly because the plugin documentation isn’t up to date, and PhoneGap is changing quick! I extended the PGPlugin class and used PluginResult to return NSDictionary objects from the Drupal iOS SDK to JavaScript.

Also, getting a PhoneGap project running with the Drupal Plugin will be a pain with version 0.1! This is mostly because PhoneGap bundles libraries into its framework that the Drupal iOS SDK needs. I’d like to make this as painless as possible to use, so that it’s easy to get started.

I’m also only exposing four methods in the 0.1 version of the plugin - node.get, user.login, user.logout, and system.connect. I’m planning on adding all of the methods that the Drupal iOS SDK exposes.

Here’s some sample code for PhoneGap that interfaces with the Drupal plugin API:

window.plugins.drupal.login(username, password, 
  successCallback,failureCallback)        
window.plugins.drupal.nodeGet(1,successCallback,failureCallback);

I’d like to get some feedback on this project from anyone who’s using PhoneGap now with Drupal to see if this solves a lot of the problems with writing a lot of JavaScript to interface with Drupal. There are also some memory management issues with camera uploads in particular that I’d like to make sure aren’t as big a problem with the Drupal plugin.

Next Steps for this project:

=================

  • Finish the node methods from the Drupal iOS SDK
  • Add the file methods from the Drupal iOS SDK
  • Add the view methods from the Drupal iOS SDK
  • Reduce the number of steps needed to add the Drupal Plugin to a PhoneGap application
  • Figure out a testing strategy
  • Document the JavaScript API
  • Create a sample application
  • Build an Android version
  • Update/test plugin with PhoneGap 1.0