SlideShare una empresa de Scribd logo
1 de 65
Descargar para leer sin conexión
James Pearce
 Sr Director, Developer Relations

 @ jamespearce
   jamesp@sencha.com
Creating and distributing
mobile web applications
     with PhoneGap
Web apps
are the future
Native apps
are the present
Native   Web

Cross-platform     ✘      ✔

   Linkable        ✘      ✔

 Discoverable      ✔      ✘

 Device APIs       ✔      ✘
Native   Web   Hybrid

Cross-platform     ✘      ✔       ✔

   Linkable        ✘      ✔       ✔

 Discoverable      ✔      ✘       ✔

 Device APIs       ✔      ✘       ✔
What is a hybrid app?
A simple hybrid application

        UIWebView
        WebView



HTML
 CSS                Stores
   JS
PhoneGap
http://phonegap.com

       MIT
+
A PhoneGap application

        UIWebView
        WebView



HTML
 CSS                Stores
   JS



         JS APIs
PhoneGap APIs
Accelerometer                                       File
Tap into the device’s motion sensor.                Hook into native file system through JavaScript.


Camera                                              Geolocation
Capture a photo using the device's camera.          Make your application location aware.


Compass                                             Media
Obtain the direction that the device is pointing.   Record and play back audio files.


Contacts                                            Network
Work with the devices contact database.             Quickly check the network state.


Device                                              Notification
Gather device specific information.                  Visual, audible, and tactile device notifications.


Events                                              Storage
Hook into native events through JavaScript.         Hook into the device’s native storage options.
Getting Started
   with iOS
http://phonegap.com
$> ./xcode4.sh seattlebars .




       http://sencha.com/x/b9
How it works
@implementation PhoneGapDelegate
...
+ (NSString*) wwwFolderName {
! return @"www";
}
+ (NSString*) startPage {
! return @"index.html";
}
...
NSString* startPage = [[self class] startPage];
NSURL *appURL = [NSURL URLWithString:startPage];
if(![appURL scheme]) {
    appURL = [NSURL fileURLWithPath:[[self class]
              pathForResource:startPage]];
}
...
NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL ...];
[webView loadRequest:appReq];
Getting Started
 with Android
How it works
package com.phonegap.exampleapp;

import android.os.Bundle;
import com.phonegap.*;

public class exampleapp extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}
Using a
Sencha Touch
 Application
$> rm -r www
$> ln -s myapp www
Don’t symlink your
source control

Don’t symlink the
entire SDK, thanks
NB these are now
in the symlink dir
Ext.setup({
  tabletStartupScreen: 'tablet_startup.png',
  phoneStartupScreen: 'phone_startup.png',
  icon: 'icon.png',
  glossOnIcon: false,
  ...
<aside>




   +        =

  Pacifist
                </aside>
$> rm -r assets/www
$> ln -s myapp assets/www
So we’re done, right?
No.
Using
Device APIs
Accelerometer                                       File
Tap into the device’s motion sensor.                Hook into native file system through JavaScript.


Camera                                              Geolocation
Capture a photo using the device's camera.          Make your application location aware.


Compass                                             Media
Obtain the direction that the device is pointing.   Record and play back audio files.


Contacts                                            Network
Work with the devices contact database.             Quickly check the network state.


Device                                              Notification
Gather device specific information.                  Visual, audible, and tactile device notifications.


Events                                              Storage
Hook into native events through JavaScript.         Hook into the device’s native storage options.
That’s what this was for
but...
Android         iOS
phonegap.js   phonegap.js
Alter entry points
package com.phonegap.exampleapp;

import android.os.Bundle;
import com.phonegap.*;

public class exampleapp extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index_a.html");
    }
}
index.html

<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="app/app.js">
    </script>
    <script type="text/javascript" src="phonegap.0.9.5.js">
    </script>
    ...
index_a.html

<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="app/app.js">
    </script>
    <script type="text/javascript" src="phonegap_a.0.9.5.js">
    </script>
    ...
deviceready event

document.addEventListener(
   "deviceready", onDeviceReady, false
);

function onDeviceReady() {
    // Now safe to use the PhoneGap API
}
Avoiding race conditions
document.addEventListener(
   "deviceready", app.mainLaunch, false
);

Ext.regApplication({
  name: "app",
  launch: function() {
     this.launched = true;
     this.mainLaunch();
  },
  mainLaunch: function() {
     if (!device || !this.launched) {return;}
     ...
  }
});
http://docs.phonegap.com
Camera
navigator.camera.getPicture(

  function(imageData) {
    var img = document.getElementById('img');
    img.src = "data:image/jpeg;base64," +
                imageData;
  },

  function (message) {
    alert('Failed because: ' + message);
  },

     { quality: 50 }

);
File I/O
var paths = navigator.fileMgr.getRootPaths();
var file = paths[0] + "write.txt";

var writer = new FileWriter(file);
writer.onwrite = function () {};
writer.write("Hello Croatia!");

var reader = new FileReader();
reader.onload = function (e) {
   alert(e.target.result);
};
reader.readAsText(file);
Contacts

navigator.service.contacts.create(
  {
    "displayName": "James Pearce",
    "organizations": ["Sencha"]
  }
).save();
Contacts Demo

http://vimeo.com/23358554
Final thoughts
Plugins
http://pmuellr.github.com/weinre/
Hybrid apps
Xcode + Eclipse
Native wrapper
 Native APIs
James Pearce
 Sr Director, Developer Relations

 @ jamespearce
   jamesp@sencha.com

Más contenido relacionado

La actualidad más candente

Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Nick Landry
 

La actualidad más candente (20)

Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Getting Acquainted with PhoneGap
Getting Acquainted with PhoneGapGetting Acquainted with PhoneGap
Getting Acquainted with PhoneGap
 
Using HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile AppsUsing HTML5 to Build Mobile Apps
Using HTML5 to Build Mobile Apps
 
Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGap
 
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
Mobile App Development with Ionic, React Native, and JHipster - Connect.Tech ...
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
Phonegap/Cordova vs Native Application
Phonegap/Cordova vs Native ApplicationPhonegap/Cordova vs Native Application
Phonegap/Cordova vs Native Application
 
Mobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance Optimization
 
Hybrid HTML5 Apps
Hybrid HTML5 AppsHybrid HTML5 Apps
Hybrid HTML5 Apps
 
Performance - a challenging craft
Performance  - a challenging craftPerformance  - a challenging craft
Performance - a challenging craft
 
jsDay - Javascript as a programming language
jsDay - Javascript as a programming languagejsDay - Javascript as a programming language
jsDay - Javascript as a programming language
 
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
 
Começando com Android
Começando com AndroidComeçando com Android
Começando com Android
 
Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGap
 
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
 
Apps with Apache Cordova and Phonegap
Apps with Apache Cordova and PhonegapApps with Apache Cordova and Phonegap
Apps with Apache Cordova and Phonegap
 
Building Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGapBuilding Hybrid Applications using PhoneGap
Building Hybrid Applications using PhoneGap
 
Phone gap
Phone gapPhone gap
Phone gap
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
 
New Age Applications with Kendo UI
New Age Applications with Kendo UINew Age Applications with Kendo UI
New Age Applications with Kendo UI
 

Similar a Creating and Distributing Mobile Web Applications with PhoneGap

WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
Robert Nyman
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
Robert Nyman
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile Development
Veronique Brossier
 
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
 
Build Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGapBuild Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGap
Allan Huang
 
PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事
longfei.dong
 
Parkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_badaParkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_bada
웹데브모바일
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Esri Nederland
 
Getting started with PhoneGap
Getting started with PhoneGapGetting started with PhoneGap
Getting started with PhoneGap
Mihai Corlan
 

Similar a Creating and Distributing Mobile Web Applications with PhoneGap (20)

WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
 
Intro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap BuildIntro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap Build
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
앱스프레소를 이용한 모바일 앱 개발(1)
앱스프레소를 이용한 모바일 앱 개발(1)앱스프레소를 이용한 모바일 앱 개발(1)
앱스프레소를 이용한 모바일 앱 개발(1)
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile Development
 
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...
 
OpenMIC March-2012.phonegap
OpenMIC March-2012.phonegapOpenMIC March-2012.phonegap
OpenMIC March-2012.phonegap
 
Build Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGapBuild Cross-Platform Mobile Application with PhoneGap
Build Cross-Platform Mobile Application with PhoneGap
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers
 
PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事
 
Parkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_badaParkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_bada
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
 
Getting started with PhoneGap
Getting started with PhoneGapGetting started with PhoneGap
Getting started with PhoneGap
 
3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 

Más de James Pearce

The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2
James Pearce
 
An Intro to Mobile HTML5
An Intro to Mobile HTML5An Intro to Mobile HTML5
An Intro to Mobile HTML5
James Pearce
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1
James Pearce
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
James Pearce
 
Building a Mobile App with Sencha Touch
Building a Mobile App with Sencha TouchBuilding a Mobile App with Sencha Touch
Building a Mobile App with Sencha Touch
James Pearce
 
Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha Touch
James Pearce
 
Cross platform mobile web apps
Cross platform mobile web appsCross platform mobile web apps
Cross platform mobile web apps
James Pearce
 
Bd conf sencha touch workshop
Bd conf sencha touch workshopBd conf sencha touch workshop
Bd conf sencha touch workshop
James Pearce
 
Building cross platform mobile web apps
Building cross platform mobile web appsBuilding cross platform mobile web apps
Building cross platform mobile web apps
James Pearce
 

Más de James Pearce (20)

Mobile Device APIs
Mobile Device APIsMobile Device APIs
Mobile Device APIs
 
The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2The City Bars App with Sencha Touch 2
The City Bars App with Sencha Touch 2
 
An Intro to Mobile HTML5
An Intro to Mobile HTML5An Intro to Mobile HTML5
An Intro to Mobile HTML5
 
A Snapshot of the Mobile HTML5 Revolution
A Snapshot of the Mobile HTML5 RevolutionA Snapshot of the Mobile HTML5 Revolution
A Snapshot of the Mobile HTML5 Revolution
 
A mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutesA mobile web app for Android in 75 minutes
A mobile web app for Android in 75 minutes
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
 
Building a Mobile App with Sencha Touch
Building a Mobile App with Sencha TouchBuilding a Mobile App with Sencha Touch
Building a Mobile App with Sencha Touch
 
Create a mobile web app with Sencha Touch
Create a mobile web app with Sencha TouchCreate a mobile web app with Sencha Touch
Create a mobile web app with Sencha Touch
 
Cross platform mobile web apps
Cross platform mobile web appsCross platform mobile web apps
Cross platform mobile web apps
 
Bd conf sencha touch workshop
Bd conf sencha touch workshopBd conf sencha touch workshop
Bd conf sencha touch workshop
 
City bars workshop
City bars workshopCity bars workshop
City bars workshop
 
San Diego Hackathon
San Diego HackathonSan Diego Hackathon
San Diego Hackathon
 
Building Cross Platform Mobile Web Apps
Building Cross Platform Mobile Web AppsBuilding Cross Platform Mobile Web Apps
Building Cross Platform Mobile Web Apps
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
An Introduction to Sencha Touch
An Introduction to Sencha TouchAn Introduction to Sencha Touch
An Introduction to Sencha Touch
 
Source Dev Con Keynote
Source Dev Con KeynoteSource Dev Con Keynote
Source Dev Con Keynote
 
Building Cloud-Based Cross-Platform Mobile Web Apps
Building Cloud-Based Cross-Platform Mobile Web AppsBuilding Cloud-Based Cross-Platform Mobile Web Apps
Building Cloud-Based Cross-Platform Mobile Web Apps
 
Building cross platform mobile web apps
Building cross platform mobile web appsBuilding cross platform mobile web apps
Building cross platform mobile web apps
 
Building tomorrow's web with today's tools
Building tomorrow's web with today's toolsBuilding tomorrow's web with today's tools
Building tomorrow's web with today's tools
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

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)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Creating and Distributing Mobile Web Applications with PhoneGap

  • 1.
  • 2. James Pearce Sr Director, Developer Relations @ jamespearce jamesp@sencha.com
  • 3. Creating and distributing mobile web applications with PhoneGap
  • 6. Native Web Cross-platform ✘ ✔ Linkable ✘ ✔ Discoverable ✔ ✘ Device APIs ✔ ✘
  • 7. Native Web Hybrid Cross-platform ✘ ✔ ✔ Linkable ✘ ✔ ✔ Discoverable ✔ ✘ ✔ Device APIs ✔ ✘ ✔
  • 8. What is a hybrid app?
  • 9. A simple hybrid application UIWebView WebView HTML CSS Stores JS
  • 11. +
  • 12. A PhoneGap application UIWebView WebView HTML CSS Stores JS JS APIs
  • 13. PhoneGap APIs Accelerometer File Tap into the device’s motion sensor. Hook into native file system through JavaScript. Camera Geolocation Capture a photo using the device's camera. Make your application location aware. Compass Media Obtain the direction that the device is pointing. Record and play back audio files. Contacts Network Work with the devices contact database. Quickly check the network state. Device Notification Gather device specific information. Visual, audible, and tactile device notifications. Events Storage Hook into native events through JavaScript. Hook into the device’s native storage options.
  • 14. Getting Started with iOS
  • 15.
  • 17.
  • 18. $> ./xcode4.sh seattlebars . http://sencha.com/x/b9
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. How it works @implementation PhoneGapDelegate ... + (NSString*) wwwFolderName { ! return @"www"; } + (NSString*) startPage { ! return @"index.html"; } ... NSString* startPage = [[self class] startPage]; NSURL *appURL = [NSURL URLWithString:startPage]; if(![appURL scheme]) { appURL = [NSURL fileURLWithPath:[[self class] pathForResource:startPage]]; } ... NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL ...]; [webView loadRequest:appReq];
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. How it works package com.phonegap.exampleapp; import android.os.Bundle; import com.phonegap.*; public class exampleapp extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/index.html"); } }
  • 30. Using a Sencha Touch Application
  • 31. $> rm -r www $> ln -s myapp www
  • 32. Don’t symlink your source control Don’t symlink the entire SDK, thanks
  • 33.
  • 34.
  • 35. NB these are now in the symlink dir
  • 36.
  • 37. Ext.setup({ tabletStartupScreen: 'tablet_startup.png', phoneStartupScreen: 'phone_startup.png', icon: 'icon.png', glossOnIcon: false, ...
  • 38.
  • 39. <aside> + = Pacifist </aside>
  • 40. $> rm -r assets/www $> ln -s myapp assets/www
  • 41.
  • 42.
  • 43.
  • 45. No.
  • 47. Accelerometer File Tap into the device’s motion sensor. Hook into native file system through JavaScript. Camera Geolocation Capture a photo using the device's camera. Make your application location aware. Compass Media Obtain the direction that the device is pointing. Record and play back audio files. Contacts Network Work with the devices contact database. Quickly check the network state. Device Notification Gather device specific information. Visual, audible, and tactile device notifications. Events Storage Hook into native events through JavaScript. Hook into the device’s native storage options.
  • 50. Android iOS phonegap.js phonegap.js
  • 51. Alter entry points package com.phonegap.exampleapp; import android.os.Bundle; import com.phonegap.*; public class exampleapp extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/index_a.html"); } }
  • 52. index.html <!doctype html> <html> <head> <script type="text/javascript" src="app/app.js"> </script> <script type="text/javascript" src="phonegap.0.9.5.js"> </script> ...
  • 53. index_a.html <!doctype html> <html> <head> <script type="text/javascript" src="app/app.js"> </script> <script type="text/javascript" src="phonegap_a.0.9.5.js"> </script> ...
  • 54. deviceready event document.addEventListener( "deviceready", onDeviceReady, false ); function onDeviceReady() {     // Now safe to use the PhoneGap API }
  • 55. Avoiding race conditions document.addEventListener( "deviceready", app.mainLaunch, false ); Ext.regApplication({ name: "app", launch: function() { this.launched = true; this.mainLaunch(); }, mainLaunch: function() { if (!device || !this.launched) {return;} ... } });
  • 57. Camera navigator.camera.getPicture( function(imageData) {     var img = document.getElementById('img');     img.src = "data:image/jpeg;base64," + imageData; }, function (message) {     alert('Failed because: ' + message); }, { quality: 50 } );
  • 58. File I/O var paths = navigator.fileMgr.getRootPaths(); var file = paths[0] + "write.txt"; var writer = new FileWriter(file); writer.onwrite = function () {}; writer.write("Hello Croatia!"); var reader = new FileReader(); reader.onload = function (e) { alert(e.target.result); }; reader.readAsText(file);
  • 59. Contacts navigator.service.contacts.create( { "displayName": "James Pearce", "organizations": ["Sencha"] } ).save();
  • 64. Hybrid apps Xcode + Eclipse Native wrapper Native APIs
  • 65. James Pearce Sr Director, Developer Relations @ jamespearce jamesp@sencha.com