PhoneGap: Building Mobile Applications with HTML/JS

Post on 13-May-2015

28,808 views 3 download

Tags:

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

Developing with Phonegap

Building mobile applications with HTML/JS

Monday, January 23, 2012

Ryan StewartWeb Developer Evangelist, Adobe

@ryanstewart

blog.digitalbackcountry.com

ryan@adobe.com

github.com/ryanstewart

Based in SeattleThings I Like:

BeerMountaineering/Hiking/BackpackingGeolocation/Mapping stuff

Monday, January 23, 2012

Agenda

• Why PhoneGap?

• Who is PhoneGap...really?

• Getting Started with PhoneGap

• PhoneGap APIs

• Extending PhoneGap

• Final Considerations

Monday, January 23, 2012

Why PhoneGap?

Monday, January 23, 2012

The moral reason:The web is awesome

Monday, January 23, 2012

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

and easier

Monday, January 23, 2012

What is PhoneGap?

Monday, January 23, 2012

Monday, January 23, 2012

Your Code

Monday, January 23, 2012

Native Web View

Your Code

Monday, January 23, 2012

Native APIs

Native Web View

Your Code

Monday, January 23, 2012

Native App - .apk, .ipa, etc

Native APIs

Native Web View

Your Code

Monday, January 23, 2012

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

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

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Monday, January 23, 2012

Getting Started

Monday, January 23, 2012

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

bin/create ~/Sites/phonegap_preso/demo Demo

Monday, January 23, 2012

Quick tour through the project structure

Monday, January 23, 2012

Demo:Hello World

Monday, January 23, 2012

Quick segue: mobile web apps versus mobile

applications

Monday, January 23, 2012

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

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

Monday, January 23, 2012

Diving into the PhoneGap APIs

Monday, January 23, 2012

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

Camera API example

Monday, January 23, 2012

Demo:Using the device APIs

Monday, January 23, 2012

Debugging

Monday, January 23, 2012

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

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

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

Monday, January 23, 2012

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

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

Demo:Debugging with Weinre

Monday, January 23, 2012

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

Monday, January 23, 2012

Demo:debug.phonegap

Monday, January 23, 2012

Extending Phonegap

Monday, January 23, 2012

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

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

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

Monday, January 23, 2012

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

Demo:PhoneGap Plugins

Monday, January 23, 2012

Final Considerations

Monday, January 23, 2012

Remember that we’re on different platforms

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Demo:PhoneGap in Action

Monday, January 23, 2012

One more thing.build.phonegap.com

Monday, January 23, 2012

The Problem:

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

Monday, January 23, 2012

The Solution:

Monday, January 23, 2012

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Monday, January 23, 2012

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

download pages public.

Monday, January 23, 2012

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

Monday, January 23, 2012

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

Monday, January 23, 2012

Demo:PhoneGap Build

Monday, January 23, 2012

Recap

• Why is PhoneGap?

• Who is PhoneGap...really?

• Getting Started with PhoneGap

• PhoneGap APIs

• Extending PhoneGap

• Final Considerations

Monday, January 23, 2012

Q&A

Ryan StewartWeb Developer Evangelist, Adobe

@ryanstewart

blog.digitalbackcountry.com

ryan@adobe.com

github.com/ryanstewart

also, Beer:

Monday, January 23, 2012