PhoneGap 3.x Mobile Application Development HOTSH T Create useful and exciting real-world apps for iOS and Android devices with 12 fantastic projects Kerri Shotts BIRMINGHAM - MUMBAI PhoneGap 3.x Mobile Application HOTSH T Development Copyright © 2014 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2013 Second Edition: May 2014 Production Reference: 1200514 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78328-792-5 www.packtpub.com Cover Image by Suresh Mogre ([email protected]) Credits Author Project Coordinator Kerri Shotts Swati Kumari Reviewers Proofreaders Gerard Braad Simran Bhogal Steve Husting Maria Gould Dhaval Nagar Ameesha Green Julio César Sánchez Paul Hindle Rajpal A. Vishal Indexers Hemangini Bari Acquisition Editors Aarthi Kumaraswamy Mariammal Chettiyar Kevin Colaco Tejal Soni Content Development Editor Graphics Susmita Panda Sabat Abhinash Sahu Technical Editors Production Coordinator Monica John Aditi Gajjar Patel Neha Mankare Cover Work Edwin Moses Aditi Gajjar Patel Shiny Poojary Copy Editors Alisha Aranha Roshni Banerjee Sarang Chari Brandt D'Mello About the Author Kerri Shotts has worked with computers for nearly 24 years. Her love for technology and programming started when she was introduced to her first computer: a Commodore 64. She obtained a degree in Computer Science and went on to become a software test engineer. After that, she was an Oracle database administrator for several years. Now, she works as a Technology Consultant creating, implementing, and maintaining custom applications (both desktop and mobile), websites, graphics and logos, and much more for her clients. You can find her blog posts at her website (www.photokandy.com), and she is active on the Google Group for PhoneGap. When she isn't working, she enjoys photography, music, and fish keeping. She is the author of two other books, Instant PhoneGap Social App Development and PhoneGap 2.x Mobile Application Development Hotshot, both published by Packt Publishing. Firstly, I will thank my family for their incredible support, even with the late night clacking of the keyboard. Thanks also to those who have made PhoneGap and Cordova such an awesome tool, and I am also thankful to those who support it on the forums. A special thanks to the technical reviewers of this book—you're all amazing! Finally, thanks to Packt Publishing and their editorial staff for making sure that everything came out just right. About the Reviewers Gerard Braad is an all-rounder when it comes to IT. He has used many programming languages on both the frontend and backend as well as mobile solutions. He is currently working in the Beijing office of ThoughtWorks. I would like to thank the contributors and community for improving PhoneGap/Cordova by suggesting new features, bugfixes, and writing great how-tos. However, I would also like to thank all the application authors who have used PhoneGap, since it shows what HTML and JavaScript are capable of doing. Steve Husting wears various hats by day, including that of a website worker, in a company that designs and manufactures radio-controlled hobby cars. By night, he writes, does calligraphy, and creates iPhone and Android apps. He posts his findings about PhoneGap app development on his blog, http://iphonedevlog.wordpress.com, which is geared towards beginners. Dhaval Nagar is an experienced Java and mobile developer who started developing JEE applications in 2006. He has been developing mobile/tablet applications since 2011 and has experience working on all major mobile platforms. His first experience with mobile devices began in 2008 on a Psion handheld computer. At present, he is running his own software development and consulting business. Prior to that, he was working as a software architect, developing large-scale industrial software using Java, EJB, JMS, Spring, and so on. Now, he is focused on developing Cordova-based mobile applications for Android, iOS, Windows Phone, and BlackBerry platforms. Besides mobile applications, he is also working on JavaScript-based frameworks such as NodeJS, Meteor, Famo.us, and AngularJS. He lives in Surat, Gujarat, India, and can be reached at [email protected] Julio César Sánchez has been a professional software developer since 2007. Over the years, he has worked with different technologies, most of them related to the Web. In 2010, he discovered PhoneGap and has been following the PhoneGap Google Group since then— learning, helping other developers, and even contributing by creating PhoneGap plugins. He spends a part of his spare time developing mobile apps and writing tutorials about PhoneGap development for the website http://www.phonegap.es. You can visit his personal website to know more about him and his work at http://www.jcesarmobile.com or follow him on Twitter @jcesarmobile. Rajpal A. Vishal is a mobile application developer with extensive experience in developing multi-platform mobile applications using Appcelerator Titanium and PhoneGap. He has contributed plugins to both the communities and is currently pursuing his Master's in Computer Science from Northeastern University, Seattle. First and foremost, I would like to thank the author of this book for producing a great book for the readers, and I would also like to thank everyone related to this book. www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Project 1: Your First Project 11 What do we build? 13 Installing Node.js and configuring SDKs 16 Installing Cordova/PhoneGap 25 Creating your first project 28 Managing your project's platforms 30 Managing your project's plugins 32 Building your project 38 Deploying your project to a simulator/device 41 Game Over..... Wrapping it up 44 Can you take the HEAT? The Hotshot Challenge 44 Project 2: Localization and Globalization 45 What do we build? 46 Creating the template 47 Creating a new project based on an existing template 49 Introducing the YASMF v0.4 framework 52 Determining the user's locale 53 Formatting numbers and dates 57 Translating text 65 Game Over..... Wrapping it up 71 Can you take the HEAT? The Hotshot Challenge 71 Project 3: Mobile Application Design 73 What do we build? 73 Designing the user interface 75 Designing the data model 82
Description: