72
Rapid native mobile app development with Drupal and Titanium / PhoneGap Scott Falconer PNWDS 2012

Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Rapid native mobile app development with

Drupal and Titanium / PhoneGap

Scott FalconerPNWDS 2012

Page 2: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Scott Falconer

• getFork.com

• @scottFalconer

• http://drupal.org/user/52557

Page 3: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

What we’ll cover

• What are native apps.

• Why native?

• Why Drupal?

• Mobile tools and frameworks.

• Drupal modules and tools.

• Putting it together.

Page 4: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

What we won’t cover

• Objective-C

• Java

Page 5: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

My goals

• More Drupal powered native apps.

Page 6: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Native apps?

• Installed on device.

• Deeper level of access / functionality.

• Not directly accessible from web.

Page 7: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 8: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Why native?

Page 9: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Distribution

Page 10: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

You can charge.

Page 11: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Native functionality

• Camera / Gallery.

• Contacts.

• Accelerometer, gyroscope.

• Location, compass, mapping.

• File System.

• Background services.

Page 12: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Should You?

• You can always do a mobile accessible site.

• You still need a mobile accessible site.

Page 13: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Be aware of the rules

• Read the TOS.

• IOS is very strict.

• Google is becoming more strict.

Page 14: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Common rejections

• Crashes / bugs.

• ‘Beta’ / ‘Demo’ / ‘Test’.

• Duplication of functionality.

• Overt marketing or advertising materials.

Page 15: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Deadlines

• There are things out of your control.

• Start early!

Page 16: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Why Drupal?

• You know it!

• Users / Content.

• Permissions.

• Existing tools and modules.

• Offload heavy lifting, secondary functionality.

Page 17: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

How to

• Device.

• Drupal.

Page 18: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Questions to ask

Page 19: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Platforms

• iOS.

• Android.

• Blackberry.

• Windows Phone

• Others.

Page 20: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Resources

• Timeline.

• Current skill set.

Page 21: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Product

Page 22: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Getting started

Page 23: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Dev accounts

• iOS: $99 / $299 yr

• Google Play: $25

• Start early!

Page 24: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools and simulators

Page 25: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 26: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 27: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Provisioning/certificates

Page 28: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Develop!

Page 29: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Hard way

• Objective-C

• Java

Page 30: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Frameworks

• PhoneGap

• Titanium

• Sencha Touch

• Unity

• Others

Page 31: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Titanium / PhoneGap

• Popular and widespread.

• Free and Open Source.

• Existing Drupal tools.

• Same end goal, fundamentally different approach.

Page 32: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 33: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 34: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

License

• Apache 2.0

• Some proprietary tools / services.

Page 35: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

How

• WebView

• Local WWW folder

• Rendered by local browser.

Page 36: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 37: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

<html><head>

<title>Capture Photo</title> <script src="cordova-2.1.0.js"></script> <script type="text/javascript">

// Button click calls this function. function capturePhoto() {

navigator.camera.getPicture( cameraSuccess, cameraError, [ cameraOptions ]

); }

</script></head>

<body><button onclick="capturePhoto();">Capture Photo</button>

</body></html>

Page 38: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Pros

• HTML5 / JS / CSS.

• You can use things like jQuery.

• Supports tons of platforms.

• Stable.

Page 39: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Cons

• Can be difficult to feel ‘native’.

• Limitations of HTML / JS

Page 40: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools

• Any JS/ HTML library.

• Be aware of size / resources.

Page 41: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 42: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Examples

• NBC flagship.

• Zipcar.

• PNWDS 2012.

Page 43: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

License

• Apache 2.0

• Some proprietary tools / services.

Page 44: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

How

• Write in JS.

• JS compiled on device / mapped to native code.

Page 45: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

function capturePhoto() {Titanium.Media.showCamera({ success: success(), error: error(), options ...});

}

var button = Titanium.UI.createButton({title: 'Open Camera',

}); button.addEventListener("click", function() {

capturePhoto();});

Page 46: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

• Window.

• View.

• Label.

Page 47: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

var window = Ti.UI.createWindow({title: ‘my title’,

}); var myView = Ti.UI.createView({});window.add(myView);

var label = Ti.UI.createLabel({text: 'Hello PNWDS 2012',

});myView.add(label);

window.open();

Page 48: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

webView

var webview = Titanium.UI.createWebView({url: 'http://www.drupal.org'

});

var webview = Titanium.UI.createWebView({html: '<html><body>Hello.</body></html>'

});

Page 49: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Extend

Page 50: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Pros

• Easily feels native.

• Lots of control.

• Same API across devices.

Page 51: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Cons

• Not direct HTML / CSS.

• New API.

• Fewer platforms.

Page 52: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools

• Titanium Studio

• Kitchen Sink

• Alloy

• Backbone / node.js

Page 53: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

The main difference

• UI

Page 54: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Drupal

• Services

• RESTWS

• Views Datasource

Page 55: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Services

Page 56: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Server

Page 57: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Auth

Page 58: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Resources

Page 59: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Online?

Page 60: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Integration

Page 61: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Assumptions

• Services

• REST server

• JSON

• Session based auth.

Page 62: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

System connect

Page 63: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Authenticate

Page 64: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Post node

Page 65: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Images / Files

• Base64

• Multipart / form-data

Page 66: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools - Drupal general

• Service views.

• Service rules.

• MASt.

• Content API.

• Any module when exposed as a service.

Page 67: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools - PhoneGap

• DrupalGap

• drupal.org/project/phonegap

• drupal.org/project/mag

• github.com/jefflinwood/Drupal-Plugin-for-PhoneGap-for-iOS

Page 68: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools - TI

• Drupanium

• Sets up endpoints

• common.js rewrite

• github.com/palantirnet/drupalcon_mobile

• github.com/teglia/pnwds_mobile

• TiaAjax

Page 69: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tips

• Drupal performance matters.

• Perform actions optimistically.

• Test in real conditions (3g, etc).

• Don’t run remote code.

Page 70: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Tools - General

• TestFlight

• Flurry

• LiveView

• Urban Airship

Page 71: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why
Page 72: Rapid native mobile app development with Drupal and ...2012.pnwdrupalsummit.org/sites/default/files/sessions/PNWDS2012.… · What we’ll cover • What are native apps. • Why

Questions