Skip to main content

Contribution to the Drupal iOS library

Developer
Jul 03, 2013

Last week I made a contribution to the Drupal iOS library, a full suite of iOS methods to natively connect iOS applications to Drupal.

We've been working on iOS + Drupal integration before. We wrote our own library first, but we didn't find it easy enough to use. It wasn't a clean solution. Later we found a more mature library called DiOS (for Drupal iOS), created by Kyle Browning from WorkHabit, so we decided to use his solution and add the things we liked in ours. DiOS is a really powerful library: registering or logging in users is only a single line of code just like updating or deleting them. Besides user management, the library is capable of working with nodes, comments, files and taxonomies. It makes a developer’s work a lot easier. After cloning the library to my machine I realized it was written for pre iOS 5.0. Apple introduced ARC since then, which makes dealing with references a lot easier: developers don’t have to deal with memory management all the time anymore. So the first step was removing the unnecessary snippets for memory management. My additions:

  • Entity management
  • In my opinion, entities are one of the most powerful advantages of Drupal. Controlling those that have Services endpoints from an iOS device is a nice addition. Using the same logic Kyle had for nodes I extended DiOS with a new class called DIOSEntity.
  • Simplified user authentication
  • User login/logout in Drupal from your browser is straightforward. Logged in users cannot login again. However, using services makes it possible to send new login requests, even if another user is already authenticated, which throws up an error message. That is why I added “verified login” to the user management class: Regardless of the login state of the system, any login attempt with a username and password is executed. If a user was logged in previously, he is first logged out. Also the logout process has been simplified. Using “verified login/logout” developers know that their user’s authentication state is what they want it to be after the successful function call: They don’t have to worry about the edge cases.
  • Username field validation for registration
  • Drupal is really strict about what characters a username can contain. In the existing DiOS, the Drupal site evaluates if the registration with the desired username is possible or not. However unless the desired username is taken, validation can be done on the iOS device too.

After all I think I managed to add value to a library that is very useful for the community. If you’re interested in using it, check it out at: https://github.com/workhabitinc/drupal-ios-sdk You can also check out a video about DIOS 2.0 and the Acquia Gardens iOS app. And keep an eye open for a follow up blogpost in which I will talk about the cool things I've been doing with this library for Drupal and iOS.

Newsletter

Articles on devportals, DX and API docs, event recaps, webinars, and more. Sign up to be up to date with the latest trends and best practices.

 

Subscribe