cross platform mobile apps with html and phonegap
play

Cross-Platform Mobile Apps with HTML and PhoneGap Christophe - PowerPoint PPT Presentation

Cross-Platform Mobile Apps with HTML and PhoneGap Christophe Coenraets @ccoenraets Resources @ccoenraets http://coenraets.org http://github.com/ccoenraets ccoenrae@adobe.com The Challenge Apple iOS Android BlackBerry QNX BlackBerry


  1. Cross-Platform Mobile Apps with HTML and PhoneGap Christophe Coenraets @ccoenraets

  2. Resources @ccoenraets http://coenraets.org http://github.com/ccoenraets ccoenrae@adobe.com

  3. The Challenge Apple iOS Android BlackBerry QNX BlackBerry Mobile Windows Phone Nokia Samsung Bada 3

  4. The Challenge Apple iOS Android BlackBerry QNX BlackBerry Mobile Windows Phone Nokia Samsung Bada 3

  5. The Challenge Objective-C Java NDK ActionScript J2ME C# C++ C++ Apple iOS Android BlackBerry QNX BlackBerry Mobile Windows Phone Nokia Samsung Bada 3

  6. The Challenge + + Objective-C Java NDK ActionScript J2ME C# C++ C++ Apple iOS Android BlackBerry QNX BlackBerry Mobile Windows Phone Nokia Samsung Bada 3

  7. From Mobile Sites to Mobile Apps 4

  8. From Mobile Sites to Mobile Apps 4

  9. The “Gap” 5

  10. The “Gap” § Package HTML/JS/CSS assets as Native Application 5

  11. The “Gap” § Package HTML/JS/CSS assets as Native Application § Expose device capabilities as JavaScript APIs consistent across platforms 5

  12. PhoneGap § PhoneGap is a “wrapper” and a “bridge” § PhoneGap is NOT : § A full-stack JavaScript framework § An architectural framework § A UI framework § A runtime 6

  13. PhoneGap works with any Framework 7

  14. Access to Device Features http://phonegap.com/about/features 8

  15. What if you need more? § PhoneGap is extensible with Plugins model that enables you to write your own native logic to access via JavaScript § All phonegap APIs are plugins § There are lots of open source plugins at https://github.com/ phonegap/phonegap-plugins 9

  16. Open Source § PhoneGap/Cordova was contributed to Apache by Adobe § You can get involved today! http://incubator.apache.org/cordova/ 10

  17. DEMO: What does a PhoneGap app look like? 11

  18. Debugging with Weinre

  19. build.phonegap.com § Continuous deployment § No SDK required § GitHub compatible § Remote debugging

  20. How do I architect a mobile HTML application?

  21. Old School

  22. Old School UI generated at the server- side in PHP, JSP, ASP, RoR, CF, ...

  23. New School <html> <head> <title>My Big App</title> <script src="my-big-app.js"></script> </head> <body></body> </html>

  24. New School <html> <head> <title>My Big App</title> <script src="my-big-app.js"></script> </head> Single Page Application <body></body> UI built dynamically at the </html> client-side in JavaScript

  25. 17

  26. “The secret to building large apps is “never build large apps” Justin Meyer, author JavaScriptMVCaaa 17

  27. Framework Landscape UI Architecture DOM 18

  28. Example: Backbone Directory http://github.com/ccoenraets/backbone- 19 directory

  29. Accessing Data JSON JSONP 20

  30. RESTful API URL HTTP Method Result api/employees GET Get all employees api/employees/1 GET Get employee #1 api/employees/1/ GET Get reports of employee #1 reports api/employees POST Add employee api/employees/1 PUT Modify employee api/employees/1 DELETE Delete employee 21

  31. Model Employee = Backbone.Model.extend({ urlRoot: "api/employees" }); emp = new Employee({firstName: 'Joe', lastName: 'Smith'}); emp.save(); 22

  32. View EmployeeView = Backbone.View.extend({ template: _.template($('#employee-tpl').html()), initialize: function () { this.render(); }, events: { "click .save": "save" }, render: function () { $(this.el).html(this.template(this.model.toJSON())); }, save: function () { this.model.save({firstName: $('#firstName').val()}); } }); 23

  33. Router Router = Backbone.Router.extend({ routes: { "" : "list", "employees/:id" : "details” }, list: function() { $('#list').html('<div>Employee List</div>'); }, details: function(id) { $('#details').html('<div>Employee Details</div>'); } }); 24

  34. Templates: Before 25

  35. Templates: After 26

  36. Templates: After Check out Mustache, underscore.js, handlebar.js, HAML, … 26

  37. Resources @ccoenraets http://coenraets.org http://github.com/ccoenraets ccoenrae@adobe.com

Recommend


More recommend