iOS & Drupal

Preview:

DESCRIPTION

Drupal from an iOS developer’s point of view.

Citation preview

IOS DRUPAL

Fotis Dimanidis@axaios iOS Devs Gr

Drupal from an iOS developer’s point of view

MY BACKGROUND

• Familiar with CMS philosophy

• Really liked it

• CMS as a (mobile) backend?

• Familiar tool in a new role?

WHY CMS?• Backend and website (/web app) in a single package

• Ease of use

• Tons of modules

• No coding necessary (in most cases)

• Own the data

SO WHY DRUPAL?• Mature CMS

• Secure & Scalable (cloud ready)

• Flexible (postgreSQL, mongoDB etc.)

• API ready (Services, RESTWS, RESTful)

• Push notifications module

• Several other modules (Authentication, Rules, etc.)

DON’T WANT TO REST?• D7

• Drupal iOS SDK

• D8

• Drupal iOS SDK

• Drupal 8 iOS SDK

• DrupalRESTKit

D7 IOS SDK EXAMPLE• Install Drupal

• Create a new sample content type (w/ custom fields etc.)

• Install Services (w/ dependencies: Ctools, Libraries)

• Enable Services & Rest server

• Create an Endpoint

CREATING ENDPOINTS

THE CODE

OBJC: GET NODE TITLENSMutableDictionary *nodeData =

[NSMutableDictionary new];

[nodeData setObject:@"12" forKey:@"nid"];

[DIOSNode nodeGet:nodeData success: ^(AFHTTPRequestOperation *operation, id responseObject) { //Get the title _titleTextField.text =

[responseObject objectForKey:@"title"]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //We failed to get the node }];

NODE BODY JSON

"body": { "und": [ { "value": “Hello world.", "summary": "", "format": "filtered_html", "safe_value": "<p>Hello world.</p>\n", "safe_summary": "" } ] },

How do I get that???

OBJC: GET CUSTOM FIELD VALUE

//Needs the "field_" prefix

NSDictionary *languageDict =

[responseObject objectForKey:@“field_address"];

NSArray *bodyValues =

[languageDict objectForKey:@“und”];

NSDictionary *descDict =

[bodyValues objectAtIndex:0];

_addressTextField.text =

[descDict objectForKey:@"value"];

GITHUB EXAMPLES

• Human Alert w/ Drupal iOS SDK demo

• OpenDatasets iOS

• Demonstrates the use of Drupal 7 iOS SDK

D7 VS D8?

• Stay with D7 for now

• D8 still in beta

• No upgrade path between betas

• Modules (Rules, Push Notifications,…) not D8 ready

TIPS N’ TRICKS• Modules to use

• Geofield• Rules• Service Tools (Services versioning!)• Push Notifications• Services Entity API• Content API• Services Views (?)

• Use entities instead of nodes (ECK module)

• MongoDB module

• Node.js module (?!)

VSServices RESTWS RESTful

SDK available Querying filters Querying filters

Select specific fields (Content API) Return specific fields List all entities

Versioning (Service Tools) Resource documentation (json) Versioning

Many Services specific modules Autocomplete call

Bloated JSON Requires plugin coding

“field_” prefix

Attention: Non conclusive list!

WHY NOT DRUPAL• Performance overhead (PHP, mySQL, Drupal

Framework)

• Maturity of iOS SDK (vs popular backend SDKs [e.g. Parse])

• Learning curve (Drupal API for custom modules)

• Invest on an expiring version (D7)

THANK YOUFotis Dimanidis

@axaios

Recommended