Top Banner
Cordova / Phonegap Packaged apps for iOS, Android & more
23

Cordova 101

Feb 08, 2017

Download

Software

Rob Dudley
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cordova 101

Cordova / PhonegapPackaged apps for iOS, Android & more

Page 2: Cordova 101

Rob just got tickets to see Star Wars at Leicester Square on the opening night.

Page 3: Cordova 101

He had to work very hard to resist the temptation to fill this presentation with Star Wars references.

Page 4: Cordova 101

You’re welcome…

Page 5: Cordova 101

Cordova 101This is the tool you’re looking for!

Package Web Apps for mobile

Build once, run (almost) anywhere

Page 6: Cordova 101

Terms

• Native

• Packaged

• Hybrid

• Web

• Package

• Device

• Emulator

• APK

Page 7: Cordova 101

What is it?

• PhoneGap == Cordova

• PhoneGap Build is a whole different thing

• Open Source Apache Project

• Builds apps from the same* code for different platforms

Page 8: Cordova 101
Page 9: Cordova 101

How it works

• Packaged HTML, CSS & JavaScript

• Interface APIs for native functionality

• Compiled using mobile dev tools du platform

• Rendered in WebView on mobile

Page 10: Cordova 101
Page 11: Cordova 101

Getting Started1. Install Node.js

2. Install Cordova

3. Create new app

4. Add a platform

5. Run

Page 12: Cordova 101

$ npm install -g cordova

$ cordova create MyApp

$ cd MyApp

$ cordova platform add browser

$ cordova run browser

Getting Started

Page 13: Cordova 101

Wait … browser?

WTF???

Page 14: Cordova 101

Before you can app it up…• You need the developer tools for your mobile platform

installed:

• Android SDK for Android / Amazon Fire

• Xcode for iOS

• BlackBerry WebWorks SDK

• Visual Studio 2013 Express for Windows Phone

• You may need a developer account (iOS)

Page 15: Cordova 101

$ cordova platform add android

$ cordova run android

Getting Started with Android

Page 16: Cordova 101

$ npm install -g ios-sim

$ npm install -g ios-deploy

$ cordova platform add iOS

$ cordova prepare

$ cordova emulate ios

Getting Started with iOS

Page 17: Cordova 101

… seriously … ?

Getting Started with Blackberry

Page 18: Cordova 101

Inside a Cordova Project• /config.xml - main config file for your Cordova App

• /www/ - web root for your app (html, css, js, images, etc.)

• /plugins/ - any plugins you want to use

• /platforms/ - configs & assets for specific platforms

• /hooks/ - scripts to do stuff at various points in the build

Page 19: Cordova 101

Plugins!• All device APIs are plugins

• Disabled by default

• Install using the CLI for cross platform apps or

• Install using Plugman for single platform apps

Page 20: Cordova 101

Plugins - search and install$ cordova plugins search bar code

$ cordova plugins add name.of.plugin

Page 21: Cordova 101

Inside your app

• Always load cordova.js

• Load assets using relative urls

• Use an SPA approach

• If using jQuery, use onDeviceReady: function() not document.ready

Page 22: Cordova 101
Page 23: Cordova 101

–Rob Dudley, just a second ago

“Talk is cheap, let’s code.”