SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
OVERVIEW AND 
INTRODUCTION 
Gabriele Falasca - Università degli studi dell’Aquila
HELLO WORLD!!! 
I’M GABRIELE FALASCA, STUDENT AT UNIVERSITÀ DEGLI 
STUDI DELL’AQUILA, AND MOBILE APPLICATION 
DEVELOPER FREELANCE 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGIN 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
Gabriele Falasca - Università degli studi dell’Aquila
SUPPORTED PLATFORMS 
NOT ONLY ANDROID IOS AND WP8!! 
● WINDOWS 8 - 8.1 
● FIREFOX OS 
● BLACKBERRY 10 
● FIREOS 
● UBUNTU PHONE 
● TIZEN 
AND SO ON... 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGIN 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
HOW TO INSTALL 
FIRST, INSTALL NPM, THEN OPEN YOUR COMMAND-LINE AND 
TYPE 
$ sudo npm install -g cordova 
THEN TYPE YOUR SUDO PASSWORD AND PRESS ENTER 
MORE INFORMATION ABOUT NPM HERE: https://www.npmjs.org/ 
Gabriele Falasca - Università degli studi dell’Aquila
HOW TO INSTALL 
THEN, YOU HAVE TO ADD ANDROID SDK PATH ON ENVIRONMENT VARIABLES 
$ export ANDROID_HOME = /yourAndroidSDKdirectory/sdk 
$ export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools 
DOWNLOAD ANDROID SDK FROM: https://developer.android.com/sdk/ 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGIN 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
CORDOVA CLI 
CREATE OUR FIRST APPLICATION 
$ cordova create test com.gabrycaos.test Test 
FIRST ARGUMENT “test” IS THE PROJECT DIRECTORY NAME 
SECOND ARGUMENT “com.gabrycaos.test” IS THE APPLICATION PACKAGE NAME 
THIRD ARGUMENT “Test” IS THE NAME OF THE APPLICATION 
Gabriele Falasca - Università degli studi dell’Aquila
PROJECT STRUCTURE 
DIRECTORIES: 
hooks/ : it may contains the scripts used to customize cordova commands 
platforms/ : it contains the projects directories of a specific platform 
plugins/ : it contains the packages of the plugin 
www/ : it contains the source code of the web applications 
config.xml : is a global configuration file 
Gabriele Falasca - Università degli studi dell’Aquila
CONFIG.XML 
IS A GLOBAL CONFIGURATION FILE 
<?xml version='1.0' encoding='utf-8'?> 
<widget id="com.pippo.test" version="0.0.1" xmlns="http://www.w3. 
org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
<name>Test</name> 
<description> 
Simple test app created for the Apache Cordova talk 
</description> 
<author email="gabrycaos@yahoo.it" href="http://gabrielefalasca.com"> 
Gabriele Falasca 
</author> 
<content src="index.html" /> 
<access origin="*" /> 
Gabriele Falasca - Università degli studi dell’Aquila 
</widget>
CONFIG.XML 
OTHER CONFIGURATIONS 
<preference name=”FullScreen” value=”true”> 
<platform name=”android”> 
<preference name=”Orientation” value=”landscape”> 
Gabriele Falasca - Università degli studi dell’Aquila 
</platform>
ADD AND REMOVE PLATFORMS 
$ cordova platform add android 
$ cordova platform remove android 
Gabriele Falasca - Università degli studi dell’Aquila
BUILD AND RUN THE APP 
$ cordova build android 
$ cordova run android 
FIRST COMMAND “cordova build” COMPILES THE SOURCE CODE 
SECOND COMMAND “cordova run” COMPILES THE CODE AND RUN IT ON 
EMULATOR OR DEVICE 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGINS 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
EVENTS 
CORDOVA PROVIDES A RICH COLLECTION OF EVENTS FOR BETTER ACCESS TO 
DEVICE CAPABILITIES 
Gabriele Falasca - Università degli studi dell’Aquila
EVENTS 
deviceready 
pause 
resume 
backbutton 
menubutton 
searchbutton 
startcallbutton 
endcallbutton 
volumedownbutton 
volumeupbutton 
EVENTS CAN BE LISTENED AND CAPTURED TROUGH W3C SPEC 
document.addEventListener(eventName, callBack) 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGINS 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
APIs 
CORDOVA PROVIDES A LARGE SET OF APIs FOR ACCESSING DEVICE FEATURES 
Gabriele Falasca - Università degli studi dell’Aquila
API: CAMERA 
Gabriele Falasca - Università degli studi dell’Aquila
CAMERA 
$ navigator.camera.getPicture(success, error, [options]) 
success: IS A CALLBACK WITH A imageURI PARAMETER OR imageData 
PARAMETER (base64 encoding of image data); 
error: IS A CALLBACK FIRED ON ERROR EVENT, IT PROVIDES AN ERROR 
Gabriele Falasca - Università degli studi dell’Aquila 
MESSAGE 
options: OPTIONAL PARAMETERS TO CUSTOMIZE CAMERA SETTINGS 
(ex. quality, destinationType, targetWidth, targetHeight, ecc…)
CAMERA 
AN EXAMPLE 
var options = {quality: 50, 
destinationType: destinationType.FILE_URI, 
sourceType: pictureSource.PHOTOLIBRARY 
}); 
navigator.camera.getPicture(success, error, options); 
function success(imageURI) { 
var element = $(“#block”); 
element.src(imageURI); 
} 
function error(message) { 
console.log(message); 
} 
Gabriele Falasca - Università degli studi dell’Aquila
API: CONTACTS 
Gabriele Falasca - Università degli studi dell’Aquila
CREATE CONTACT 
navigator.contacts.create(properties) 
properties: IS A MAP OF PROPERTIES OF THE CONTACT OBJECT, PROPERTIES 
CAN BE: 
● id: UNIQUE IDENTIFIER OF THE CONTACT 
● displayName: NAME OF THE CONTACT 
● name: AN OBJECT THAT CONTAINS INFORMATION OF THE 
PERSON 
● phoneNumbers: AN ARRAY WITH ALL PHONE NUMBERS OF 
THE CONTACT 
● and so on... 
Gabriele Falasca - Università degli studi dell’Aquila
CREATE CONTACT 
AN EXAMPLE 
var contact = navigator.contacts.create({ 
"displayName": “Pablo“ 
}); 
var name = new ContactName(); 
name.firsName = “Gabriele“; 
name.lastName = “Falasca“; 
contact.name = name; 
contact.birthday = new Date(“19 May 1989"); 
contact.save(success,error); 
function success(contact) { 
alert(“Contact saved!”); 
}; 
function error(error) { 
console.log("Error = " + error.code); 
}; 
Gabriele Falasca - Università degli studi dell’Aquila
FIND CONTACT 
navigator.contacts.find(fields, success, error, options) 
● fields: ARE THE PARAMETERS OF THE CONTACT WILL BE RETURNED 
TO success FUNCTION 
● success: SUCCESS CALLBACK 
● error: ERROR CALLBACK 
● option: LIST OF SETTING FOR FILTER THE CONTACTS 
Gabriele Falasca - Università degli studi dell’Aquila
FIND CONTACT 
AN EXAMPLE 
function onSuccess(contacts) { 
alert('Found ' + contacts.length + ' contacts.'); 
}; 
function onError(contactError) { 
alert('Error!'); 
}; 
// find all contacts with 'Gabriele' in any name field 
var options = new ContactFindOptions(); 
options.filter="Gabriele"; 
options.multiple=true; 
var fields = ["displayName", "name"]; 
navigator.contacts.find(fields, onSuccess, onError, options); 
Gabriele Falasca - Università degli studi dell’Aquila
API: GEOLOCATION 
Gabriele Falasca - Università degli studi dell’Aquila
GET USER POSITION 
navigator.geolocation.getCurrentPosition(success, error, [options]) 
success: IS A CALLBACK WITH A Position OBJECT AS A PARAMETER 
error: IS A CALLBACK FIRED ON ERROR EVENT, IT PROVIDES A PositionError 
OBJECT AS A PARAMETER 
options: OPTIONAL PARAMETERS TO CUSTOMIZE SETTINGS 
Gabriele Falasca - Università degli studi dell’Aquila
GET USER POSITION 
AN EXAMPLE 
var onSuccess = function(position) { 
alert('Latitude: ' + position.coords.latitude + 'n' + 
'Longitude: ' + position.coords.longitude + 'n' + 
'Altitude: ' + position.coords.altitude + 'n' + 
'Accuracy: ' + position.coords.accuracy + 'n' + 
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + 'n' + 
'Speed: ' + position.coords.speed + 'n' +); 
}; 
// onError Callback receives a PositionError object 
function onError(error) { 
alert('code: ' + error.code + 'n' + 
'message: ' + error.message + 'n'); 
} 
navigator.geolocation.getCurrentPosition(onSuccess, onError); 
Gabriele Falasca - Università degli studi dell’Aquila
WATCH USER POSITION 
SIMILARLY AT LAST EXAMPLE WE CAN WATCH THE USER POSITION WITH THE METHOD wathPosition OF 
THE navigator.geolocation OBJECT. IN THIS CASE WE HAVE TO PASS A timeOut ARGUMENT AT THE 
OPTIONS OBJECT. 
navigator.geolocation.watchPosition(success, error, [options]) 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGINS 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
PLUGINS 
Gabriele Falasca - Università degli studi dell’Aquila
PLUGINS 
THERE ARE TWO SIMPLE WAY TO ADD PLUGIN AT OUR CORDOVA APP: 
FOR CORDOVA BUILT-IN PLUGINS: 
cordova plugin add <plugin package name> 
FOR THIRD PARTIES PLUGINS: 
cordova plugin add <url of plugin repository> 
Gabriele Falasca - Università degli studi dell’Aquila
PLUGINS 
REMOVING PLUGINS: 
cordova plugin rm <plugin package name> 
FOR MORE INFORMATION ABOUT CORDOVA PLUGINS VISIT http://plugins.cordova.io/ 
Gabriele Falasca - Università degli studi dell’Aquila
PLUGINS 
EXAMPLES 
INSTALLING A CORDOVA BUILT-IN PLUGIN (InAppBrowser): 
cordova plugin add org.apache.cordova.inappbrowser 
FOR THIRD PARTIES PLUGINS (PushPlugin) * : 
cordova plugin add https://github.com/phonegap-build/PushPlugin.git 
* yes, Cordova supports Phonegap plugins 
Gabriele Falasca - Università degli studi dell’Aquila
ROADMAP 
INTRO 
HOW TO INSTALL 
CORDOVA CLI 
EVENTS 
APIs 
PLUGINS 
RIPPLE EMULATOR 
Gabriele Falasca - Università degli studi dell’Aquila
RIPPLE EMULATOR 
http://ripple.incubator.apache.org/ 
Gabriele Falasca - Università degli studi dell’Aquila
RIPPLE EMULATOR 
WHAT IS? 
RIPPLE IS A WEB-BASED MOBILE SIMULATOR, IDEAL FOR RAPID DEVELOPMENT 
OF MOBILE APPLICATION DEVELOPED WITH WEB BASED FRAMEWORK, SUCH 
APACHE CORDOVA 
Gabriele Falasca - Università degli studi dell’Aquila
HOW TO INSTALL 
OPEN YOUR COMMAND LINE AND TYPE 
$ sudo npm install -g ripple-emulator 
THEN TYPE YOUR PASSWORD AND PRESS ENTER 
Gabriele Falasca - Università degli studi dell’Aquila
HOW TO USE 
FROM COMMAND-LINE GO IN YOUR PROJECT DIRECTORY AND TYPE: 
$ ripple emulate --disable-web-security 
ARGUMENT --disable-web-security IS USED FOR START YOUR 
BROWSER WITH DISABLED CORS 
(IT WORKS IN CHROME, I’M NOT SURE IN FIREFOX AND OTHER BROWSERS) 
Gabriele Falasca - Università degli studi dell’Aquila
RIPPLE INTERFACE 
WE’LL SEE THIS ARGUMENT DIRECTLY WITH THE EMULATOR! :) 
Gabriele Falasca - Università degli studi dell’Aquila
MOST FAMOUS BRANDS USING 
CORDOVA 
Gabriele Falasca - Università degli studi dell’Aquila
QUESTIONS??? 
Gabriele Falasca - Università degli studi dell’Aquila
THANKS A LOT!!! 
facebook.com/gabrycaos 
plus.google.com/+GabrieleFalasca1989 
it.linkedin.com/in/falascagabriele 
(SOON) http://gabrielefalasca.com 
gabrycaos@yahoo.it 
Gabriele Falasca - Università degli studi dell’Aquila

Contenu connexe

Tendances

symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
Fabien Potencier
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
Christian Heilmann
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
Xamarin
 

Tendances (20)

Developing Native Mobile Apps Using JavaScript, ApacheCon NA 2014
Developing Native Mobile Apps Using JavaScript, ApacheCon NA 2014Developing Native Mobile Apps Using JavaScript, ApacheCon NA 2014
Developing Native Mobile Apps Using JavaScript, ApacheCon NA 2014
 
Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In Action
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginners
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
Cordova Tutorial
Cordova TutorialCordova Tutorial
Cordova Tutorial
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
 
Getting Your Hooks into Cordova
Getting Your Hooks into CordovaGetting Your Hooks into Cordova
Getting Your Hooks into Cordova
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
Turbocharge your API strategy with SDK
Turbocharge your API strategy with SDKTurbocharge your API strategy with SDK
Turbocharge your API strategy with SDK
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
 
A I R Presentation Dev Camp Feb 08
A I R  Presentation  Dev Camp  Feb 08A I R  Presentation  Dev Camp  Feb 08
A I R Presentation Dev Camp Feb 08
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
 
Appium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation IntroductionAppium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation Introduction
 
Leveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data TransferLeveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
 
Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2
 

En vedette

V. liqviat 2009
V. liqviat 2009V. liqviat 2009
V. liqviat 2009
nera24mx
 
Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici ecc
Luciano Colosio
 
DotNetToscana - Sessione TypeScript
DotNetToscana - Sessione TypeScriptDotNetToscana - Sessione TypeScript
DotNetToscana - Sessione TypeScript
Sinergia Totale
 

En vedette (19)

Node.js: perche' tutto questo hype?
Node.js: perche' tutto questo hype?Node.js: perche' tutto questo hype?
Node.js: perche' tutto questo hype?
 
V. liqviat 2009
V. liqviat 2009V. liqviat 2009
V. liqviat 2009
 
node.js everywhere
node.js everywherenode.js everywhere
node.js everywhere
 
Aulas linux
Aulas linuxAulas linux
Aulas linux
 
Corso base di Tecnologie WEB - Primi passi in javascript
Corso base di Tecnologie WEB - Primi passi in javascriptCorso base di Tecnologie WEB - Primi passi in javascript
Corso base di Tecnologie WEB - Primi passi in javascript
 
Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici ecc
 
node.js e Postgresql
node.js e Postgresqlnode.js e Postgresql
node.js e Postgresql
 
DotNetToscana - Sessione TypeScript
DotNetToscana - Sessione TypeScriptDotNetToscana - Sessione TypeScript
DotNetToscana - Sessione TypeScript
 
Introduzione a jQuery
Introduzione a jQueryIntroduzione a jQuery
Introduzione a jQuery
 
Introduzione a JavaScript
Introduzione a JavaScriptIntroduzione a JavaScript
Introduzione a JavaScript
 
Workshop AngularJs, Cordova, Ionic - Politecnico di Milano
Workshop AngularJs, Cordova, Ionic - Politecnico di MilanoWorkshop AngularJs, Cordova, Ionic - Politecnico di Milano
Workshop AngularJs, Cordova, Ionic - Politecnico di Milano
 
Il Web orientato al futuro: Express, Angular e nodeJS
Il Web orientato al futuro: Express, Angular e nodeJS Il Web orientato al futuro: Express, Angular e nodeJS
Il Web orientato al futuro: Express, Angular e nodeJS
 
Web base-03-js-numeri stringearray
Web base-03-js-numeri stringearrayWeb base-03-js-numeri stringearray
Web base-03-js-numeri stringearray
 
Da JavaScript a TypeScript
Da JavaScript a TypeScriptDa JavaScript a TypeScript
Da JavaScript a TypeScript
 
Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?Node js: che cos'è e a che cosa serve?
Node js: che cos'è e a che cosa serve?
 
Roma linuxday 2013 - nodejs
Roma linuxday 2013 - nodejsRoma linuxday 2013 - nodejs
Roma linuxday 2013 - nodejs
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 

Similaire à Apache Cordova: Overview and Introduction

Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
Robert Nyman
 

Similaire à Apache Cordova: Overview and Introduction (20)

Phone gap 12 things you should know
Phone gap 12 things you should knowPhone gap 12 things you should know
Phone gap 12 things you should know
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is FineCocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
CocoaConf Chicago 2017: Media Frameworks and Swift: This Is Fine
 
Native Javascript apps with Phonegap - De Keijzer
Native Javascript apps with Phonegap - De KeijzerNative Javascript apps with Phonegap - De Keijzer
Native Javascript apps with Phonegap - De Keijzer
 
Native Javascript apps with PhoneGap 11-04-2014 Codemotion Rome
Native Javascript apps with PhoneGap 11-04-2014 Codemotion RomeNative Javascript apps with PhoneGap 11-04-2014 Codemotion Rome
Native Javascript apps with PhoneGap 11-04-2014 Codemotion Rome
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Cordova training : Cordova plugins
Cordova training : Cordova pluginsCordova training : Cordova plugins
Cordova training : Cordova plugins
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016
How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016
How To Structure Go Applications - Paul Bellamy - Codemotion Milan 2016
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]The 2016 Android Developer Toolbox [MOBILIZATION]
The 2016 Android Developer Toolbox [MOBILIZATION]
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605Summit2011 satellites-robinf-20110605
Summit2011 satellites-robinf-20110605
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Apache Cordova: Overview and Introduction

  • 1. OVERVIEW AND INTRODUCTION Gabriele Falasca - Università degli studi dell’Aquila
  • 2. HELLO WORLD!!! I’M GABRIELE FALASCA, STUDENT AT UNIVERSITÀ DEGLI STUDI DELL’AQUILA, AND MOBILE APPLICATION DEVELOPER FREELANCE Gabriele Falasca - Università degli studi dell’Aquila
  • 3. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGIN RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 4. Gabriele Falasca - Università degli studi dell’Aquila
  • 5. SUPPORTED PLATFORMS NOT ONLY ANDROID IOS AND WP8!! ● WINDOWS 8 - 8.1 ● FIREFOX OS ● BLACKBERRY 10 ● FIREOS ● UBUNTU PHONE ● TIZEN AND SO ON... Gabriele Falasca - Università degli studi dell’Aquila
  • 6. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGIN RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 7. HOW TO INSTALL FIRST, INSTALL NPM, THEN OPEN YOUR COMMAND-LINE AND TYPE $ sudo npm install -g cordova THEN TYPE YOUR SUDO PASSWORD AND PRESS ENTER MORE INFORMATION ABOUT NPM HERE: https://www.npmjs.org/ Gabriele Falasca - Università degli studi dell’Aquila
  • 8. HOW TO INSTALL THEN, YOU HAVE TO ADD ANDROID SDK PATH ON ENVIRONMENT VARIABLES $ export ANDROID_HOME = /yourAndroidSDKdirectory/sdk $ export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools DOWNLOAD ANDROID SDK FROM: https://developer.android.com/sdk/ Gabriele Falasca - Università degli studi dell’Aquila
  • 9. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGIN RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 10. CORDOVA CLI CREATE OUR FIRST APPLICATION $ cordova create test com.gabrycaos.test Test FIRST ARGUMENT “test” IS THE PROJECT DIRECTORY NAME SECOND ARGUMENT “com.gabrycaos.test” IS THE APPLICATION PACKAGE NAME THIRD ARGUMENT “Test” IS THE NAME OF THE APPLICATION Gabriele Falasca - Università degli studi dell’Aquila
  • 11. PROJECT STRUCTURE DIRECTORIES: hooks/ : it may contains the scripts used to customize cordova commands platforms/ : it contains the projects directories of a specific platform plugins/ : it contains the packages of the plugin www/ : it contains the source code of the web applications config.xml : is a global configuration file Gabriele Falasca - Università degli studi dell’Aquila
  • 12. CONFIG.XML IS A GLOBAL CONFIGURATION FILE <?xml version='1.0' encoding='utf-8'?> <widget id="com.pippo.test" version="0.0.1" xmlns="http://www.w3. org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>Test</name> <description> Simple test app created for the Apache Cordova talk </description> <author email="gabrycaos@yahoo.it" href="http://gabrielefalasca.com"> Gabriele Falasca </author> <content src="index.html" /> <access origin="*" /> Gabriele Falasca - Università degli studi dell’Aquila </widget>
  • 13. CONFIG.XML OTHER CONFIGURATIONS <preference name=”FullScreen” value=”true”> <platform name=”android”> <preference name=”Orientation” value=”landscape”> Gabriele Falasca - Università degli studi dell’Aquila </platform>
  • 14. ADD AND REMOVE PLATFORMS $ cordova platform add android $ cordova platform remove android Gabriele Falasca - Università degli studi dell’Aquila
  • 15. BUILD AND RUN THE APP $ cordova build android $ cordova run android FIRST COMMAND “cordova build” COMPILES THE SOURCE CODE SECOND COMMAND “cordova run” COMPILES THE CODE AND RUN IT ON EMULATOR OR DEVICE Gabriele Falasca - Università degli studi dell’Aquila
  • 16. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGINS RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 17. EVENTS CORDOVA PROVIDES A RICH COLLECTION OF EVENTS FOR BETTER ACCESS TO DEVICE CAPABILITIES Gabriele Falasca - Università degli studi dell’Aquila
  • 18. EVENTS deviceready pause resume backbutton menubutton searchbutton startcallbutton endcallbutton volumedownbutton volumeupbutton EVENTS CAN BE LISTENED AND CAPTURED TROUGH W3C SPEC document.addEventListener(eventName, callBack) Gabriele Falasca - Università degli studi dell’Aquila
  • 19. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGINS RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 20. APIs CORDOVA PROVIDES A LARGE SET OF APIs FOR ACCESSING DEVICE FEATURES Gabriele Falasca - Università degli studi dell’Aquila
  • 21. API: CAMERA Gabriele Falasca - Università degli studi dell’Aquila
  • 22. CAMERA $ navigator.camera.getPicture(success, error, [options]) success: IS A CALLBACK WITH A imageURI PARAMETER OR imageData PARAMETER (base64 encoding of image data); error: IS A CALLBACK FIRED ON ERROR EVENT, IT PROVIDES AN ERROR Gabriele Falasca - Università degli studi dell’Aquila MESSAGE options: OPTIONAL PARAMETERS TO CUSTOMIZE CAMERA SETTINGS (ex. quality, destinationType, targetWidth, targetHeight, ecc…)
  • 23. CAMERA AN EXAMPLE var options = {quality: 50, destinationType: destinationType.FILE_URI, sourceType: pictureSource.PHOTOLIBRARY }); navigator.camera.getPicture(success, error, options); function success(imageURI) { var element = $(“#block”); element.src(imageURI); } function error(message) { console.log(message); } Gabriele Falasca - Università degli studi dell’Aquila
  • 24. API: CONTACTS Gabriele Falasca - Università degli studi dell’Aquila
  • 25. CREATE CONTACT navigator.contacts.create(properties) properties: IS A MAP OF PROPERTIES OF THE CONTACT OBJECT, PROPERTIES CAN BE: ● id: UNIQUE IDENTIFIER OF THE CONTACT ● displayName: NAME OF THE CONTACT ● name: AN OBJECT THAT CONTAINS INFORMATION OF THE PERSON ● phoneNumbers: AN ARRAY WITH ALL PHONE NUMBERS OF THE CONTACT ● and so on... Gabriele Falasca - Università degli studi dell’Aquila
  • 26. CREATE CONTACT AN EXAMPLE var contact = navigator.contacts.create({ "displayName": “Pablo“ }); var name = new ContactName(); name.firsName = “Gabriele“; name.lastName = “Falasca“; contact.name = name; contact.birthday = new Date(“19 May 1989"); contact.save(success,error); function success(contact) { alert(“Contact saved!”); }; function error(error) { console.log("Error = " + error.code); }; Gabriele Falasca - Università degli studi dell’Aquila
  • 27. FIND CONTACT navigator.contacts.find(fields, success, error, options) ● fields: ARE THE PARAMETERS OF THE CONTACT WILL BE RETURNED TO success FUNCTION ● success: SUCCESS CALLBACK ● error: ERROR CALLBACK ● option: LIST OF SETTING FOR FILTER THE CONTACTS Gabriele Falasca - Università degli studi dell’Aquila
  • 28. FIND CONTACT AN EXAMPLE function onSuccess(contacts) { alert('Found ' + contacts.length + ' contacts.'); }; function onError(contactError) { alert('Error!'); }; // find all contacts with 'Gabriele' in any name field var options = new ContactFindOptions(); options.filter="Gabriele"; options.multiple=true; var fields = ["displayName", "name"]; navigator.contacts.find(fields, onSuccess, onError, options); Gabriele Falasca - Università degli studi dell’Aquila
  • 29. API: GEOLOCATION Gabriele Falasca - Università degli studi dell’Aquila
  • 30. GET USER POSITION navigator.geolocation.getCurrentPosition(success, error, [options]) success: IS A CALLBACK WITH A Position OBJECT AS A PARAMETER error: IS A CALLBACK FIRED ON ERROR EVENT, IT PROVIDES A PositionError OBJECT AS A PARAMETER options: OPTIONAL PARAMETERS TO CUSTOMIZE SETTINGS Gabriele Falasca - Università degli studi dell’Aquila
  • 31. GET USER POSITION AN EXAMPLE var onSuccess = function(position) { alert('Latitude: ' + position.coords.latitude + 'n' + 'Longitude: ' + position.coords.longitude + 'n' + 'Altitude: ' + position.coords.altitude + 'n' + 'Accuracy: ' + position.coords.accuracy + 'n' + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + 'n' + 'Speed: ' + position.coords.speed + 'n' +); }; // onError Callback receives a PositionError object function onError(error) { alert('code: ' + error.code + 'n' + 'message: ' + error.message + 'n'); } navigator.geolocation.getCurrentPosition(onSuccess, onError); Gabriele Falasca - Università degli studi dell’Aquila
  • 32. WATCH USER POSITION SIMILARLY AT LAST EXAMPLE WE CAN WATCH THE USER POSITION WITH THE METHOD wathPosition OF THE navigator.geolocation OBJECT. IN THIS CASE WE HAVE TO PASS A timeOut ARGUMENT AT THE OPTIONS OBJECT. navigator.geolocation.watchPosition(success, error, [options]) Gabriele Falasca - Università degli studi dell’Aquila
  • 33. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGINS RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 34. PLUGINS Gabriele Falasca - Università degli studi dell’Aquila
  • 35. PLUGINS THERE ARE TWO SIMPLE WAY TO ADD PLUGIN AT OUR CORDOVA APP: FOR CORDOVA BUILT-IN PLUGINS: cordova plugin add <plugin package name> FOR THIRD PARTIES PLUGINS: cordova plugin add <url of plugin repository> Gabriele Falasca - Università degli studi dell’Aquila
  • 36. PLUGINS REMOVING PLUGINS: cordova plugin rm <plugin package name> FOR MORE INFORMATION ABOUT CORDOVA PLUGINS VISIT http://plugins.cordova.io/ Gabriele Falasca - Università degli studi dell’Aquila
  • 37. PLUGINS EXAMPLES INSTALLING A CORDOVA BUILT-IN PLUGIN (InAppBrowser): cordova plugin add org.apache.cordova.inappbrowser FOR THIRD PARTIES PLUGINS (PushPlugin) * : cordova plugin add https://github.com/phonegap-build/PushPlugin.git * yes, Cordova supports Phonegap plugins Gabriele Falasca - Università degli studi dell’Aquila
  • 38. ROADMAP INTRO HOW TO INSTALL CORDOVA CLI EVENTS APIs PLUGINS RIPPLE EMULATOR Gabriele Falasca - Università degli studi dell’Aquila
  • 39. RIPPLE EMULATOR http://ripple.incubator.apache.org/ Gabriele Falasca - Università degli studi dell’Aquila
  • 40. RIPPLE EMULATOR WHAT IS? RIPPLE IS A WEB-BASED MOBILE SIMULATOR, IDEAL FOR RAPID DEVELOPMENT OF MOBILE APPLICATION DEVELOPED WITH WEB BASED FRAMEWORK, SUCH APACHE CORDOVA Gabriele Falasca - Università degli studi dell’Aquila
  • 41. HOW TO INSTALL OPEN YOUR COMMAND LINE AND TYPE $ sudo npm install -g ripple-emulator THEN TYPE YOUR PASSWORD AND PRESS ENTER Gabriele Falasca - Università degli studi dell’Aquila
  • 42. HOW TO USE FROM COMMAND-LINE GO IN YOUR PROJECT DIRECTORY AND TYPE: $ ripple emulate --disable-web-security ARGUMENT --disable-web-security IS USED FOR START YOUR BROWSER WITH DISABLED CORS (IT WORKS IN CHROME, I’M NOT SURE IN FIREFOX AND OTHER BROWSERS) Gabriele Falasca - Università degli studi dell’Aquila
  • 43. RIPPLE INTERFACE WE’LL SEE THIS ARGUMENT DIRECTLY WITH THE EMULATOR! :) Gabriele Falasca - Università degli studi dell’Aquila
  • 44. MOST FAMOUS BRANDS USING CORDOVA Gabriele Falasca - Università degli studi dell’Aquila
  • 45. QUESTIONS??? Gabriele Falasca - Università degli studi dell’Aquila
  • 46. THANKS A LOT!!! facebook.com/gabrycaos plus.google.com/+GabrieleFalasca1989 it.linkedin.com/in/falascagabriele (SOON) http://gabrielefalasca.com gabrycaos@yahoo.it Gabriele Falasca - Università degli studi dell’Aquila