Building a simple iPad Application with Drupal 7, Part 1
At DrupalCamp Colorado 2011, I created a birds-of-a-feather session on “Going Mobile with Drupal”. There were quite a few of us there, with all kinds of experience - we talked about using jQuery Mobile with Drupal and about connecting iPhone apps to Drupal using the Services module, REST, and either JSON or plist XML. Lots of interest in building RESTful web services with Drupal to support mobile apps.
Drupal 7 makes an ideal back-end for mobile apps, because it already has everything you need for content authoring and permissions built-in. There isn’t any reason to write a lot of server-side code to add a forum or groups or blogs to your mobile app. Another advantage is the large Drupal ecosystem of consultancies, developers, books, training, and conferences that you can turn to for help.
[
The night before the birds-of-a-feather, I built an iPad app to show the Drupal IOS SDK in use with an almost out-of-the-box Drupal 7 site. Here’s the github repo for my iPad demo app for Drupal - I’m not going to submit it to the App Store :)
Configuring Drupal to be the back end for Mobile
Right out of the box, Drupal 7 isn’t going to work as a back-end for mobile apps. You will need to install Services 3 to make it possible for Drupal to act as a REST server for its content. You’ll also need to set up an endpoint URL for your REST service, and tell Drupal which resources to expose at that endpoint. This is all much easier in Drupal 7/Services 3 than it was in Drupal 6/Services 2 - if you are using Drupal 6, see my article on Using Drupal 6 with the REST Server.
Drupal Services Modules for REST Server
The first step is to install the modules you’ll need for Services 3:
Services 7.x-3.0-rc3 - requires the ctools 7.x module
To make Services work with the Drupal iOS SDK for iPhone app development, you’ll also need:
Rest Server PLIST 7.x-1.0 - enable rest_server and rest_server_plist
If you’re also planning to retrieve views from your mobile app (and that’s most of the power here) you’ll need to install the Views module and the Services_views module. Services_views exposes Views as a resource to Services
Views 7.x-3.0-beta3 - enable Views and Views UI
Services_views 7.x-1.x-dev - enable Services_views
To keep this focused, I’m not including directions on how to install modules here - read the Drupal.org handbook on installing modules.
In the next post, I’ll cover how to configure Services so you can use Drupal as the server side of a mobile solution!