access to everything, best performance – Store deployment – Knowledge of each platform required • Web – One codebase (really?) – No deployment – Browsers are operating ‘systems’ these days • Hybrid – HTML5 & JavaScript – put into a native app shell – Leverage native features through plugins • Hybrid2 – Hybrid + explicitly mix native and web elements
framework & tools to create native apps from an HTML5/JS codebase – Start with wrapping your HTML5 code into native app shell – Hook into platform features & events with APIs – Extend app functionality with plugins • Latest incarnation – New base architecture – New tools, new APIs, new platforms – Cloud-based companion
donated the PhoneGap codebase to the Apache Software Foundation (ASF) for incubation – Requirement to ensure intellectual property was unfettered by trademark ambiguity – Hard requirement to rename PhoneGap in its open source form as a project incubating at Apache • PhoneGap is a distribution of Apache Cordova – Think of Apache Cordova as the engine that powers PhoneGap – Similar to how WebKit is the engine that powers Chrome or Safari, well…
based on plugins – Lightweight core • Application implemented as a web page – References whatever CSS, JavaScript, images, media files, or other resources are necessary for it to run – Executes as a web view control within the native application wrapper – Interact with various device features by referencing cordova.js file which provides API bindings
any IDE – node.js-based – Multiple platform support – Distributed via npm • Cordova CLI – Unifies all platforms into a single project structure – Making it easy to maintain single codebase for multiple platforms • Phonegap CLI – Similar to Cordova CLI, different commands & syntax – Integrates with PhoneGap Build • Plugman – Automated discovery, installation, and removal of both core and custom plugins
about app (cross platform) – Specifies parameters affecting how it works (e.g. responding to orientation shifts) – Adheres to the W3C's Packaged Web App, or Widget, specification • Features – Out-of-the-box native features via JavaScript API – Need to be enabled, implemented as plugins • Plugins – Bridges bit of functionality between web view and native platform the application is running on $ phonegap local plugin add https://git-‐wip-‐us.apache.org/repos/asf/cordova-‐plugin-‐device.git
via API • Customizations – Use merges directory to add or override files for specific platform • Whitelisting – Security model that controls access to outside domains – Default security policy allows access to any site – Before moving your application to production, review whitelist and declare access to specific network domains and subdomains
JavaScript interface used across all platforms – Native implementations following platform-specific plugin interfaces that the JavaScript calls into – All of the core Cordova APIs are implemented using this architecture • Installation via CLIs – Based on plugin specification • Mapping from native implementation class to JS-exposed name in config.xml • Online plugin registry – http://plugins.cordova.io/
class CordovaPlugin from package org.apache.cordova.plugin – iOS ObjectiveC base class CDVPlugin • Threading – watch out – iOS: executed in the same thread as the UI. If your plugin requires a great deal of processing or requires a blocking call, you should use a background thread – Android: JavaScript in the WebView does not run on the UI thread. It runs on the WebCore thread. The execute method also runs on the WebCore thread
links? – Web browser (as plugin) that displays in the app when calling window.open – E.g. for authentication/authorization with web-based providers (OAuth) • WebView (aka Cleaver) – Enabling hybrid2: Adding Cordova WebView to native apps – E.g. native navigation, transitions, look & feel - with HTML5 content
Safari Web Inspector to debug HTML5/JS code – On simulator/emulator or device – Always use console.log() • Other remote debugging tools like Weinre (local/Cloud) – E.g. http://debug.phonegap.com/
mobile (or: ‚smart‘) apps • Building hybrid apps gets easier with PhoneGap 3.0 – Still a lot of work for tools and IDE builders • Typical 80/20 scenarios can be easily realized with PG – For the rest build plugins or embed PG into native apps • MVC-style JS frameworks like AngularJS make development & maintenance a breeze – Combined with mobile-optimized CSS frameworks