Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How PhoneGap really works

How PhoneGap really works

PhoneGap (PhoneGap API's, PhoneGap plugins, PhoneGap Build) from behind

Ilya Pukhalski

February 12, 2013
Tweet

More Decks by Ilya Pukhalski

Other Decks in Programming

Transcript

  1. — That mobile mobile world... — What is PhoneGap? -

    A brief history of PhoneGap - How PhoneGap works - PhoneGap APIs - Plugins - Cons and limitations — PhoneGap Build — The future is closer than you think 4
  2. 7 +

  3. PhoneGap is an open source framework that enables to build

    cross-platform hybrid mobile applications using web technologies (HTML, CSS, JavaScript). 14
  4. iPhoneDevCamp 2008 17 PhoneGap 1.0 2009 Migration to Apache Cordova

    2012 IBM get involved into development late 2009 PhoneGap Build official launch late 2012
  5. 19

  6. 20

  7. 21

  8. 22

  9. 24

  10. 27 — Accelerometer — Camera — Compass (excl. iPhone 3/3G,

    BlackBerry OS 5+ and Symbian) — Contacts (excl. WebOS) — File (excl. WebOS, Symbian, Bada) — Geolocation — Media (excl. BlackBerry OS 5+, WebOS, Symbian, Bada) — Network — Notification — Storage (excl. Bada)
  11. 28

  12. 36

  13. 42 iOS native code #import <Cordova/CDVPlugin.h> @interface HelloWorld : CDVPlugin

    @end #import "HelloWorld.h" @implementation HelloWorld @end HelloWorld.h HelloWorld.m Inheritance
  14. 43 Adding methods #import <Cordova/CDVPlugin.h> @interface HelloWorld : CDVPlugin -

    (void)add:(CDVInvokedUrlCommand*)command; @end #import "HelloWorld.h" @implementation HelloWorld - (void)add:(CDVInvokedUrlCommand*)command { } @end HelloWorld.h HelloWorld.m Instance method Instance method
  15. 44 Retrieving arguments #import "HelloWorld.h" @implementation HelloWorld - (void)add:(CDVInvokedUrlCommand*)command {

    double a = [[command.arguments objectAtIndex:0] doubleValue]; double b = [[command.arguments objectAtIndex:1] doubleValue]; double result = a + b; } @end HelloWorld.m Retrieve arguments; Addition.
  16. 45 Sending the result #import "HelloWorld.h" @implementation HelloWorld - (void)add:(CDVInvokedUrlCommand*)command

    { double a = [[command.arguments objectAtIndex:0] doubleValue]; double b = [[command.arguments objectAtIndex:1] doubleValue]; double result = a + b; CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:result]; [self writeJavascript: [pluginResult toSuccessCallbackString:command.callbackId]]; } @end HelloWorld.m Send result back
  17. — Fast changing inconsistent API — Lacks and inaccuracies in

    documentation — Some device specific API's are still unavailable for some OS — Dealing with cross-platform web development issues 49
  18. — PhoneGap Build is a cloud service — PhoneGap Build

    API can help in establishing CI — No need to have different environment OS and SDK's to build an application 52 PhoneGap Build Pros