PhoneGap Essentials
()
About this ebook
Related to PhoneGap Essentials
Related ebooks
PhoneGap and AngularJS for Cross-platform Development Rating: 0 out of 5 stars0 ratingsWindows Phone 7.5: Building Location Aware Applications Rating: 0 out of 5 stars0 ratingsInstant PhoneGap Social App Development Rating: 0 out of 5 stars0 ratingsJavaScript Mobile Application Development Rating: 0 out of 5 stars0 ratingsGetting Started with NativeScript Rating: 0 out of 5 stars0 ratingsMastering AndEngine Game Development Rating: 0 out of 5 stars0 ratingsKnockoutJS Blueprints Rating: 0 out of 5 stars0 ratingsPhoneGap for Enterprise Rating: 0 out of 5 stars0 ratingsUnreal Engine 4 AI Programming Essentials Rating: 0 out of 5 stars0 ratingsApplication Development with Qt Creator - Second Edition Rating: 4 out of 5 stars4/5Asynchronous Android Rating: 4 out of 5 stars4/5Getting Started with UDOO Rating: 0 out of 5 stars0 ratingsWebRTC Blueprints Rating: 0 out of 5 stars0 ratingsAndroid Application Development with Maven Rating: 0 out of 5 stars0 ratingsLearn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition) Rating: 0 out of 5 stars0 ratingsAugmented Reality for Android Application Development Rating: 0 out of 5 stars0 ratingsAngularJS Deployment Essentials Rating: 0 out of 5 stars0 ratingsiOS 9 Game Development Essentials Rating: 0 out of 5 stars0 ratingsXamarin 4 By Example Rating: 0 out of 5 stars0 ratingsIntroducing Spring Framework: A Primer Rating: 0 out of 5 stars0 ratingsObjective-C Memory Management Essentials Rating: 0 out of 5 stars0 ratingsRabbitMQ Essentials Rating: 0 out of 5 stars0 ratingsNode.js High Performance Rating: 0 out of 5 stars0 ratingsExt JS Data-driven Application Design Rating: 0 out of 5 stars0 ratingsUltimate Flutter for Cross-Platform App Development Rating: 0 out of 5 stars0 ratingsIBM Worklight Mobile Application Development Essentials Rating: 0 out of 5 stars0 ratingsRubyMotion iOS Develoment Essentials Rating: 0 out of 5 stars0 ratingsUnity AI Programming Essentials Rating: 0 out of 5 stars0 ratingsDeploying Node.js Rating: 5 out of 5 stars5/5
Computers For You
Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Deep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsCompTIA Security+ Practice Questions Rating: 2 out of 5 stars2/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 0 out of 5 stars0 ratingsNetwork+ Study Guide & Practice Exams Rating: 4 out of 5 stars4/5Ultimate Guide to Mastering Command Blocks!: Minecraft Keys to Unlocking Secret Commands Rating: 5 out of 5 stars5/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 0 out of 5 stars0 ratingsPractical Lock Picking: A Physical Penetration Tester's Training Guide Rating: 5 out of 5 stars5/5ChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 0 out of 5 stars0 ratingsAP Computer Science Principles Premium, 2024: 6 Practice Tests + Comprehensive Review + Online Practice Rating: 0 out of 5 stars0 ratingsChildhood Unplugged: Practical Advice to Get Kids Off Screens and Find Balance Rating: 0 out of 5 stars0 ratingsThe Professional Voiceover Handbook: Voiceover training, #1 Rating: 5 out of 5 stars5/5Dark Aeon: Transhumanism and the War Against Humanity Rating: 5 out of 5 stars5/5Elon Musk Rating: 4 out of 5 stars4/5Master Builder Roblox: The Essential Guide Rating: 4 out of 5 stars4/5101 Awesome Builds: Minecraft® Secrets from the World's Greatest Crafters Rating: 4 out of 5 stars4/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5
Reviews for PhoneGap Essentials
0 ratings0 reviews
Book preview
PhoneGap Essentials - Turkovic Ivan
Table of Contents
PhoneGap Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Get up and Running with PhoneGap
A brief history
What is PhoneGap?
Where can it be used?
What PhoneGap is not
Competition
PhoneGap or Cordova?
Setting up a local development environment
Mac OS
Linux
Windows
Summary
2. Mobile Platform Support
Supported platforms
Supported features by platform
Support for development
PhoneGap Build
Platform support
Using PhoneGap Build
The PhoneGap Developer App
How to use it
Summary
3. Command-line Interface
Introduction to a command-line interface
PhoneGap CLI versus Cordova CLI
Installing the PhoneGap CLI
Creating a new project
Creating a Hello project
Creating a new project
Managing platforms
Adding a platform
Listing platforms
Removing a platform
Keeping platforms up-to-date
Application description
Creating a project from a template
Managing the project
Application preview
Preparing an application
Compiling an application
Building an application
Running an application
Emulating an application
Using PhoneGap Build
Authentication
Preparing the application
Building the application
Summary
4. Plugin Support
Introducing plugins
What is a plugin?
Support for different mobile platforms
Installing plugins
Command-line Interface
Finding plugins
Adding plugins
Listing plugins
Removing plugins
Plugman
Installing Plugman
Searching for plugins
Installing plugins
Removing plugins
npm
Plugins
Battery Status
Camera
Contacts
Device
The Device Motion plugin
Device position orientation
Dialogs
FileSystem
File Transfer
Geolocation
Globalization
InAppBrowser
Media
Media Capture
Network Information
Splashscreen
Vibration
StatusBar
Summary
5. First PhoneGap Application
Starting a new application
Creating a new application
Setting up the initial code
Project folder structure
Core PhoneGap events
The deviceready event
The pause event
The resume event
Essential plugins
The Device plugin
The Network Information plugin
The StatusBar plugin
The Dialogs plugin
Summary
6. Accessing Native APIs
Native APIs
Device status plugins
Motion sensing plugins
Media functionality plugins
Notification plugins
The Battery Status plugin
The Battery Status event
The Low Battery event
The Critical Battery event
The Device Motion plugin
The getCurrentAcceleration method
watchAcceleration
clearWatch
The Device Orientation plugin
getCurrentHeading
watchHeading
clearWatch
The Geolocation plugin
getCurrentPosition
watchPosition
clearWatch
The Position object
The Coordinates object
The Vibration plugin
Vibrate
Standard vibrate
Vibrating with a pattern (Android and Windows only)
Cancelling the vibration (not supported in iOS)
Summary
7. Accessing Media Content
Introducing multimedia
Media
File management
Contacts
File Transfer
The FileTransfer object
The FileUploadResult object
Upload
Download
Abort
Contacts
Contact
The Contact object
ContactName
ContactField
ContactAddress
ContactOrganization
The create method
Find
pickContact
Camera
getPicture
cleanup
InAppBrowser
The InAppBrowser object
The InAppBrowserEvent object
Open
Summary
8. Application Development Workflow
An introduction to a development workflow
Web project development
Native platform development
Best practices
Use local assets for the UI
Network access for data
Non-blocking UI
CSS animations
Click events
Performance
Optimize the image assets
Offline status
Load only what you need
Transparency
JSHint
Testing
Debugging
Desktop browsers
The PhoneGap emulator
Weinre
iOS Debugging
Xcode
Safari Remote Debugging
Android debugging
User interface
Summary
Index
PhoneGap Essentials
PhoneGap Essentials
Copyright © 2015 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: September 2015
Production reference: 1310815
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-468-7
www.packtpub.com
Credits
Author
Ivan Turkovic
Reviewers
Johnathan Iannotti
Yousuf Qureshi
Anthony Rumsey
Kasper Souren
Tomasz Trejderowski
Commissioning Editor
Neil Alexander
Acquisition Editor
Subho Gupta
Content Development Editor
Manasi Pandire
Technical Editor
Bharat Patil
Copy Editors
Stephen Copestake
Tasneem Fatehi
Project Coordinator
Suzanne Coutinho
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Production Coordinator
Nilesh R. Mohite
Cover Work
Nilesh R. Mohite
About the Author
Ivan Turkovic is an experienced developer with over 15 years of programming experience. He developed an interest for software development at an early age of 8, when he started to write Basic code on his first Commodore 64 computer. Seeing the potential of what could be done with it encouraged him to pursue his studies in computer science. He has extensive experience of mobile and web application development and has delivered many enterprise and consumer solutions. His favorite languages are Ruby, Swift, and JavaScript. Ivan has always been interested in emerging technologies. In his spare time, when he is not working on another exciting pet project, he is traveling and learning new human
languages. He writes his thoughts at http://ivanturkovic.com.
In the past, he has helped found several technology start-ups. As a founder and digital consultant at Blaeg (http://www.blaeg.com), he helps companies, start-ups, and individuals integrate technology into their business and strategies. He also conducts trainings and workshops and writes blogs to share his knowledge with the community.
To my family: thank you for your support and patience with me over the last few months. You won't hear, I am busy; I have a book to write
from me anytime soon, promise!
This book is my first attempt at becoming a technical book writer. Writing it has been a fun and exciting experience, but it was also quite harsh on some occasions. There were moments between work and personal issues when I thought I couldn't make it, but here we are! What I want to do now is thank all the wonderful people who have accompanied me on this journey.
About the Reviewers
Johnathan Iannotti is a software engineer and geek on an epic journey of life. His experience spans 15 years of technology solutions for start-ups, financial companies, healthcare, and military industries. He is passionate about web technology and has been creating hybrid apps since their inception. A full-stack developer by trade, he loves UX/UI, frontend development, and mobile.
He works for USAA, creating mobile applications for over 27,000 employees that serve their military membership. He is also a combat veteran, having served almost a decade in the United States Army.
Johnathan spends his time innovating, coding, and making the best of it all. When he's not plugged in, he spends as much time as he can with his beautiful wife and two children, who make it all possible.
You can follow Johnathan on Twitter at @notticode or visit his website, http://www.johnforhire.com/.
Yousuf Qureshi is an early adopter of technology and gadgets and has profound experience in the e-commerce, social media, analytics, and mobile apps sectors. He is a Cloudera Certified Developer for Apache Hadoop (CCDH).
His expertise includes development, technology turnaround, consulting, and architecture. He is also an experienced developer of Android, iOS, Blackberry, ASP.net MVC, Java, MapReduce, Distributed Search and Inverted Index algorithms, Hadoop, Hive, Apache Pig, Media API integration, and multiplatform applications.
Yousuf has also reviewed jQuery Drag and Drop Grids How-To and Monitoring Hadoop for Packt Publishing.
To my (late) grandparents, Abdullah Tanwar and Yasin Khokar.
Anthony Rumsey is a software developer at Adobe with a passion for creating well-designed and engaging user experiences. During his 15-year career, he has focused on the integration of web technologies into Adobe's enterprise software. More recently, his focus has shifted to exploring the capabilities of the mobile web and mobile apps, including contributions to the responsive simulator, touch interface, and PhoneGap integration in Adobe Experience Manager. Anthony happily resides in Ottawa, Canada, with his wife and two children.
Kasper Souren was born in the Netherlands and has been working with Internet technologies across the globe since 1998 for various companies and institutions, including CouchSurfing, Mercedes-Benz, Geekcorps Mali, the Dutch tax authorities, and the biggest Dutch social network. As of 2013, his favorite technology stack is Meteor with CoffeeScript. He's a cofounder of Hitchwiki.org, the ultimate resource for hitchhikers. You can visit his website at http://guaka.org/ and also connect with him on Twitter at @guaka.
Tomasz Trejderowski is a middle-aged developer from Poland with hands-on experience in many programming languages and a wide range of IT aspects. He has been programming computers since the very first Commodore 64, which he received in his youth, and thus poses over 20 years of overall software development experience. You can access repositories and contributions on his GitHub profile and GitHub organizations that he is a part of at https://github.com/trejder.
He is a full-time PhoneGap and Yii2 developer and mobile market entrepreneur, constantly working on many innovative international start-ups and projects. You can visit his company website at http://gaman.pl/ for more details.
Tomasz holds a PhD degree and has authored five books and over 40 articles (mostly in Polish). He is a happy husband of a wonderful wife and the father of two beautiful daughters.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.
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
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.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a 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 9 entirely free books. Simply use your login credentials for immediate access.
Preface
When you learn a new programming language, the traditional first step is to go through a Hello, World tutorial that teaches you everything you need to know to get a basic program working, such as one that prints the text Hello, World on the screen. In this sense, this book is the Hello, World tutorial to build your first PhoneGap application.
This book provides you with a great way to get started with PhoneGap and also gives detailed examples from the different areas that PhoneGap covers. It can