phonegap: building mobile applications with html/js

64
Developing with Phonegap Building mobile applications with HTML/JS Monday, January 23, 2012

Upload: ryan-stewart

Post on 13-May-2015

28.815 views

Category:

Technology


3 download

DESCRIPTION

An overview of PhoneGap. Covers the basics about what PhoneGap is, how to get started, how to use the device APIs, and how to debug it along with some other things to consider when building mobile applications with HTML/JS/CSS.

TRANSCRIPT

Page 1: PhoneGap: Building Mobile Applications with HTML/JS

Developing with Phonegap

Building mobile applications with HTML/JS

Monday, January 23, 2012

Page 2: PhoneGap: Building Mobile Applications with HTML/JS

Ryan StewartWeb Developer Evangelist, Adobe

@ryanstewart

blog.digitalbackcountry.com

[email protected]

github.com/ryanstewart

Based in SeattleThings I Like:

BeerMountaineering/Hiking/BackpackingGeolocation/Mapping stuff

Monday, January 23, 2012

Page 3: PhoneGap: Building Mobile Applications with HTML/JS

Agenda

• Why PhoneGap?

• Who is PhoneGap...really?

• Getting Started with PhoneGap

• PhoneGap APIs

• Extending PhoneGap

• Final Considerations

Monday, January 23, 2012

Page 4: PhoneGap: Building Mobile Applications with HTML/JS

Why PhoneGap?

Monday, January 23, 2012

Page 5: PhoneGap: Building Mobile Applications with HTML/JS

The moral reason:The web is awesome

Monday, January 23, 2012

Page 6: PhoneGap: Building Mobile Applications with HTML/JS

The realistic reasonCross platform applications with HTML/JS will be faster

and easier

Monday, January 23, 2012

Page 7: PhoneGap: Building Mobile Applications with HTML/JS

What is PhoneGap?

Monday, January 23, 2012

Page 8: PhoneGap: Building Mobile Applications with HTML/JS

Monday, January 23, 2012

Page 9: PhoneGap: Building Mobile Applications with HTML/JS

Your Code

Monday, January 23, 2012

Page 10: PhoneGap: Building Mobile Applications with HTML/JS

Native Web View

Your Code

Monday, January 23, 2012

Page 11: PhoneGap: Building Mobile Applications with HTML/JS

Native APIs

Native Web View

Your Code

Monday, January 23, 2012

Page 12: PhoneGap: Building Mobile Applications with HTML/JS

Native App - .apk, .ipa, etc

Native APIs

Native Web View

Your Code

Monday, January 23, 2012

Page 13: PhoneGap: Building Mobile Applications with HTML/JS

PhoneGap uses the native browser on the device to render the HTML/CSS/JS

Keep in mind that can affect the experienceIt also keeps apps nice and small

Monday, January 23, 2012

Page 14: PhoneGap: Building Mobile Applications with HTML/JS

PhoneGap uses the native project format for each platform.Open, emulate, and test from within the native development environment!

Monday, January 23, 2012

Page 15: PhoneGap: Building Mobile Applications with HTML/JS

Because it’s using the native projects it’s fully extendable.

Monday, January 23, 2012

Page 16: PhoneGap: Building Mobile Applications with HTML/JS

PhoneGap provides a JavaScript Library that reaches out into the native APIs.That means anything the device supports is doable.

Monday, January 23, 2012

Page 17: PhoneGap: Building Mobile Applications with HTML/JS

PhoneGap is completely open source and has been submitted to the Apache Foundation.

Monday, January 23, 2012

Page 19: PhoneGap: Building Mobile Applications with HTML/JS

The entire project is available on Githubhttps://github.com/cordova

Monday, January 23, 2012

Page 20: PhoneGap: Building Mobile Applications with HTML/JS

Getting Started

Monday, January 23, 2012

Page 21: PhoneGap: Building Mobile Applications with HTML/JS

There are multiple ways to “start” with PhoneGap.The project includes command line tools, IDE plugins, and Dreamweaver 5.5 ships with PhoneGap support.

Monday, January 23, 2012

Page 22: PhoneGap: Building Mobile Applications with HTML/JS

bin/create ~/Sites/phonegap_preso/demo Demo

Monday, January 23, 2012

Page 23: PhoneGap: Building Mobile Applications with HTML/JS

Quick tour through the project structure

Monday, January 23, 2012

Page 24: PhoneGap: Building Mobile Applications with HTML/JS

Demo:Hello World

Monday, January 23, 2012

Page 25: PhoneGap: Building Mobile Applications with HTML/JS

Quick segue: mobile web apps versus mobile

applications

Monday, January 23, 2012

Page 26: PhoneGap: Building Mobile Applications with HTML/JS

Very important to keep in mind that we’re building a mobile app, not a mobile web app.Let’s look at jQuery Mobile

Monday, January 23, 2012

Page 27: PhoneGap: Building Mobile Applications with HTML/JS

You can use ANY framework you want, but try to design for an app. (I kind of like Bootstrap)

Monday, January 23, 2012

Page 28: PhoneGap: Building Mobile Applications with HTML/JS

Diving into the PhoneGap APIs

Monday, January 23, 2012

Page 29: PhoneGap: Building Mobile Applications with HTML/JS

Out of the box, PhoneGap provides support for a number of basic device APIs

- Accelerometer- Camera- Capture- Compass- Connection- Contacts- Device- Events- File- Geolocation- Media- Network- Notification- Storage

Monday, January 23, 2012

Page 30: PhoneGap: Building Mobile Applications with HTML/JS

Camera API example

Monday, January 23, 2012

Page 31: PhoneGap: Building Mobile Applications with HTML/JS

Demo:Using the device APIs

Monday, January 23, 2012

Page 32: PhoneGap: Building Mobile Applications with HTML/JS

Debugging

Monday, January 23, 2012

Page 33: PhoneGap: Building Mobile Applications with HTML/JS

It’s all just HTML/JS, so you can use your browser!Take advantage of Chrome Developer tools/Firebug to test your app’s UI.

Monday, January 23, 2012

Page 34: PhoneGap: Building Mobile Applications with HTML/JS

But what about Device APIs?Because we’re in the web view, there is no

way to do line-by-line debugging.

Monday, January 23, 2012

Page 35: PhoneGap: Building Mobile Applications with HTML/JS

Luckily we have Weinre, which lets us debug and manipulate the DOM from our PCs.

Monday, January 23, 2012

Page 36: PhoneGap: Building Mobile Applications with HTML/JS

Weinre can be configured as a server (there is a Mac application) and uses the developer tools from Chrome to provide hooks into the mobile app.

Monday, January 23, 2012

Page 37: PhoneGap: Building Mobile Applications with HTML/JS

Drop in a <script> tag on a remote server and Weinre will let you use the Developer Tools on your apps.Requires internet access, so keep that in mind.

Monday, January 23, 2012

Page 38: PhoneGap: Building Mobile Applications with HTML/JS

Demo:Debugging with Weinre

Monday, January 23, 2012

Page 39: PhoneGap: Building Mobile Applications with HTML/JS

But, a much easier way:http://debug.phonegap.com/

Monday, January 23, 2012

Page 40: PhoneGap: Building Mobile Applications with HTML/JS

Demo:debug.phonegap

Monday, January 23, 2012

Page 41: PhoneGap: Building Mobile Applications with HTML/JS

Extending Phonegap

Monday, January 23, 2012

Page 42: PhoneGap: Building Mobile Applications with HTML/JS

For added functionality PhoneGap provides a plug-in mechanism.Includes OS-specific code/libraries and the JS to use it in PhoneGapSome of the helpful ones: PayPal, Facebook, Push Notification

Monday, January 23, 2012

Page 43: PhoneGap: Building Mobile Applications with HTML/JS

Plug-is are one of the areas that show off the power of a hybrid web/native approach.There are a ton of native-centric SDKs (like Facebook) that provide a great native experience. We can use those!

Monday, January 23, 2012

Page 44: PhoneGap: Building Mobile Applications with HTML/JS

Available at https://github.com/phonegap/phonegap-plugins

Monday, January 23, 2012

Page 45: PhoneGap: Building Mobile Applications with HTML/JS

This app can just use the plugins.barcodeScanner.scan method to call out to some native code that reads and parses a barcode.

Monday, January 23, 2012

Page 46: PhoneGap: Building Mobile Applications with HTML/JS

Demo:PhoneGap Plugins

Monday, January 23, 2012

Page 47: PhoneGap: Building Mobile Applications with HTML/JS

Final Considerations

Monday, January 23, 2012

Page 48: PhoneGap: Building Mobile Applications with HTML/JS

Remember that we’re on different platforms

Monday, January 23, 2012

Page 50: PhoneGap: Building Mobile Applications with HTML/JS

Some important performance implications:Currently only iOS hardware accelerates CSS3 transitions.

Monday, January 23, 2012

Page 51: PhoneGap: Building Mobile Applications with HTML/JS

Couple of tips:Always test features first (if !supported)For UI-specifics, you can use the device

class to get device info

Monday, January 23, 2012

Page 52: PhoneGap: Building Mobile Applications with HTML/JS

Demo:PhoneGap in Action

Monday, January 23, 2012

Page 53: PhoneGap: Building Mobile Applications with HTML/JS

One more thing.build.phonegap.com

Monday, January 23, 2012

Page 54: PhoneGap: Building Mobile Applications with HTML/JS

The Problem:

You’re building a cross-platform app, but dealing with a lot of native projects

Monday, January 23, 2012

Page 55: PhoneGap: Building Mobile Applications with HTML/JS

The Solution:

Monday, January 23, 2012

Page 56: PhoneGap: Building Mobile Applications with HTML/JS

Monday, January 23, 2012

Page 57: PhoneGap: Building Mobile Applications with HTML/JS

Build includes git support so you can use git and host projects on PhoneGap or build a project from Github.

Monday, January 23, 2012

Page 58: PhoneGap: Building Mobile Applications with HTML/JS

Build lets you define individuals as tester/developer which changes permissions on the project accordingly.

Monday, January 23, 2012

Page 59: PhoneGap: Building Mobile Applications with HTML/JS

You can use Build as your testing distribution as well by making the

download pages public.

Monday, January 23, 2012

Page 60: PhoneGap: Building Mobile Applications with HTML/JS

Will (soon) support popular plugins so that you can build plugins right into the build process.

Monday, January 23, 2012

Page 61: PhoneGap: Building Mobile Applications with HTML/JS

Supports multiple PhoneGap versions so you can target a wide range of devices.

Monday, January 23, 2012

Page 62: PhoneGap: Building Mobile Applications with HTML/JS

Demo:PhoneGap Build

Monday, January 23, 2012

Page 63: PhoneGap: Building Mobile Applications with HTML/JS

Recap

• Why is PhoneGap?

• Who is PhoneGap...really?

• Getting Started with PhoneGap

• PhoneGap APIs

• Extending PhoneGap

• Final Considerations

Monday, January 23, 2012

Page 64: PhoneGap: Building Mobile Applications with HTML/JS

Q&A

Ryan StewartWeb Developer Evangelist, Adobe

@ryanstewart

blog.digitalbackcountry.com

[email protected]

github.com/ryanstewart

also, Beer:

Monday, January 23, 2012