Read an Excerpt
Beginning Building Mobile Application Development in the Cloud
By Richard Rodger
John Wiley & SonsCopyright © 2012 John Wiley & Sons, Ltd
All right reserved.
Chapter OneIntroducing Cloud-Based Mobile Apps
WHAT YOU WILL LEARN IN THIS CHAPTER:
* Using your existing skills as a web developer to build mobile apps
* Understanding how HTML5 will be used as an app-development standard
* Using the WebKit browser engine for app development
* Creating a mobile web app that responds to touch
* Installing and using the nginx web server
The code examples in this book show you how to build complete apps. You are never left to put together the pieces yourself. The code is simple and includes error-handling logic, so you'll learn how to build production-ready apps and systems.
Over the course of this book, you will build three complete applications. You'll learn how to put together all the elements of the technology stack, and you'll learn about a wide range of technologies and services. This book will enable you to get to work but avoids unnecessary detail and theory.
This book is an accelerator for your skills. You can use it to efficiently make the leap into mobile and cloud development. Rather than attempting to be a reference for all the details, which you can find on the web anyway, it is a stepping stone for your skills.
HOW TO BUILD MOBILE APPS IN THE CLOUD
This book describes how to build apps that run on the new generation of smart mobile devices. It also shows how to build out the business logic behind these apps, and how to run that business logic in a cloud hosting environment, such as that provided by Amazon.
This book focuses on the two leading platforms: iPhone and Android. These two, between them, cover the vast majority of smartphones and provide access to the largest market.
NOTE In this book, the term iPhone should be taken as shorthand for any iOS-based device, including iPad and the iPod Touch devices. Similarly, the term Android refers to any device running Android version 2.1 or higher, including any of the Android tablets that are competing with the iPad.
It's important to understand the types of apps that can run on mobile devices:
* Mobile web apps — These apps are really just websites, designed to function in an app-like way. They run in a web browser on a device.
* Purely native apps — These apps are written in a device-specific language, using a device-specific programming interface: Objective-C for iPhone apps or Java for Android apps. Native apps can access all the capabilities of the device and can take many forms, from simple utility apps to advanced 3-D games.
* Hybrid native apps — For these apps, you use HTML to build the user interface but wrap the HTML in a native container. Such apps can access some of the native capabilities of the device but can still be developed using HTML.
In this book you will learn how to build mobile web apps and hybrid apps.
Using Your Existing Skill Set
As a web developer, you already possess all the skills you need to be a mobile app developer as well. If you can build websites, you can build mobile apps. If you are a web developer wanting to build mobile apps, you do not need to learn new languages such as Objective-C or Java. You do not even need to learn new languages to build the code for servers that support your app.
Determining What Tools You Need
You'll need some development tools in order to fully explore the examples in this book. You will certainly find a physical iPhone or Android device very useful for testing and development. You need to run mobile apps on an actual device to really understand how they will behave once users get hold of them.
To a certain extent, you can develop the apps and code examples in this book on any of the three major operating systems: Mac, Windows, or Linux. However, you will find that a Mac is the best choice, simply because the iPhone development tools from Apple can only run on a Mac. Your Mac can also run the server code quite easily. One thing you should do is upgrade to the latest version of the Mac OS X operating system, as this will support the most up-to-date versions of the iPhone development tools.
Windows and Linux are also acceptable, although you will have to do a little more configuration and setup work. In particular, on Windows, you will need to install the Cygwin UNIX environment so that you can run Node.js. Cygwin is available from www.cygwin.com. As discussed in Chapter, 11, you will also have to rely on third-party services to build hybrid native iPhone apps.
You can build mobile web apps and the necessary server code using your existing development tools. All you need is a good code editor, and I'm sure you've already chosen a favorite for coding websites. You'll also be using the command line quite a bit, especially for the server code. But don't worry if you're not comfortable with the command line; this book gives you exactly the commands you need to run.
Later in this book, you'll need to download and install the software development kits (SDKs) for iPhone and Android development. These SDKs are provided as part of the Xcode (for iPhone) and Eclipse (for Android) development environments. Xcode runs only on a Mac, but you can run Eclipse on all three operating systems.
The final development tool you'll use is the Safari web browser. You can download this directly from the Apple website: www.apple.com/safari. You will use Safari as a test and deployment tool because Safari is built with the open source WebKit browser engine. This browser engine is used on both iPhone and Android, and it is the web browser environment for which you need to develop. In your coding work cycle, you will use the desktop Safari browser as your test system.
The Skills You'll Learn
As you work through this book, you'll learn and enhance a wide range of skills. These skills will cover the entire mobile app technology stack, from the device, to the server, to the database. These will be practical skills, and theory will be kept to a minimum. All the code examples in this book create complete, fully working apps. You'll be able to use them as foundations for your own work.
You'll make good use of the new features in HTML5 when you build mobile web apps and HTML5-based native apps. The Safari browser and the WebKit engine have good support for many of the features of HTML5. You'll be able to use local on-device storage, app caching, geolocation, and even audio and video support.
You'll also learn about the special metatags and design considerations needed for mobile web app development. These allow you to deal with different screen sizes and device capabilities. They also allow you to define home screen icons and loading screens for your app.
The app on a device is only part of the story. The aim of this book is to teach you how to create mobile apps that provide complete services. This means you'll need to write server code that handles some of your business logic, such as user account management, user data storage, and integration with third-party cloud services. You'll also learn how to provide social media logins using Facebook and Twitter.
You'll need a place to put your server-side code, so you'll learn how to host your code in the cloud, using Amazon Web Services (AWS). AWS is a full cloud-hosting system provided by Amazon that lets you create your servers and store images and files; it provides a nearly infinite database. You'll learn how to set up and configure an Amazon server and how to access the Amazon services over the web.
Finally, you'll learn how to work with next-generation databases that go beyond traditional tables, columns, and rows. You'll learn how to work with these schemaless database systems and how to synchronize them with the data on your mobile device.
TWO BIG IDEAS ABOUT THE APP INDUSTRY
This book is based on two predictions about where the app industry is going:
* Cloud computing will be the primary way to build the service infrastructure for apps — Most app developers accept this idea.
* Using HTML5 is a great way to build apps and will only become better — This view is still quite controversial.
The following sections take a closer look at these predictions and how they affect you, as a web developer and as a mobile app developer.
Web Apps and the Future
There are two types of web apps: mobile web apps and hybrid native apps. A mobile web app is delivered as a website and runs in a web browser on a mobile device. You can bookmark web apps on the home screen of the device, and you can give them icons and loading screens (as you'll see in Chapter 4). The user experience with mobile web apps is essentially different from that of native apps, but you can remove many of the differences.
This book will show you how to create both types of apps. You should carefully consider which approach is the best choice. The huge advantage of mobile web apps is that they are ultimately just websites, which means they do not have to be submitted to any app stores for approval. You can update them as frequently as you like, and they can be accessed from almost all smartphones (although functionality may be limited outside the iPhone and Android platforms).
However, hybrid native apps have the advantage of being proper apps that are listed in the app stores. They can use a device to its full potential, and you can extended these apps with native code, if necessary. You might be surprised to learn that a great many "purely" native apps actually make extensive use of HTML5 WebView controls. This is the main way to display rich text interfaces, even for purely native apps.
The following are the main reasons to develop an app using HTML5, whether as a mobile web app or within a hybrid native wrapper:
* Cross-platform — Your app is automatically cross-platform, and you have to develop it only once. The minor debugging required to handle device browser differences is inconsequential compared to the huge effort required to port an entire app from one platform language to another.
* Standards compliant — Long after the current set of mobile platforms have become historical entries in Wikipedia, your HTML5 app will still be running. HTML, as a technology choice, is a completely safe bet. It is quickly becoming the primary means of building user interfaces on any device, including tablet computers.
* Low-friction deployment — You can launch and update mobile web apps immediately, without waiting for a third-party approval process. You have complete control over content, user base, and commercial activities. No vendor is powerful enough to control the web.
* Easy to learn — You already have a good knowledge of web languages, so you can start building apps right away just by learning to deal with the particularities of mobile web app development. You do not need to invest any time in learning a new language such as Objective-C, which has limited use outside its own ecosystem.
The Cloud as the Future
Cloud computing means many things. For mobile app developers, it provides the ability to build apps that millions of people can use. Cloud computing makes it easier to handle large and growing numbers of users.
This book shows you how to build your own cloud-based system from the ground up, using the Amazon cloud. You can use the same basic approach with other cloud vendors, such as Rackspace or Joyent. Chapter 11 covers the use of higher-level services that completely remove the need for any server configuration and just run your code for you.
Excerpted from Beginning Building Mobile Application Development in the Cloud by Richard Rodger Copyright © 2012 by John Wiley & Sons, Ltd. Excerpted by permission of John Wiley & Sons. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.