www.it-ebooks.info Appcelerator Titanium Business Application Development Cookbook Over 40 hands-on recipes to quickly and efficiently create business grade Titanium Enterprise apps Benjamin Bahrenburg BIRMINGHAM - MUMBAI www.it-ebooks.info Appcelerator Titanium Business Application Development Cookbook Copyright © 2013 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: June 2013 Production Reference: 1180613 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84969-534-3 www.packtpub.com Cover Image by Will Kewley ([email protected]) www.it-ebooks.info Credits Author Project Coordinator Benjamin Bahrenburg Hardik Patel Reviewers Proofreader David Bankier Katherine Tarr Imraan Jhetam Indexer Acquisition Editor Hemangini Bari Joanne Fitzpatrick Graphics Lead Technical Editor Abhinash Sahu Ritika Dewani Production Coordinators Technical Editors Melwyn Dsa Prasad Dalvi Zahid Shaikh Pushpak Poddar Cover Work Melwyn Dsa Zahid Shaikh www.it-ebooks.info About the Author Benjamin Bahrenburg is a developer, blogger, speaker, and consultant. Ben specializes in building enterprise solutions using mobile technologies, geolocation services, and domain-specific languages. Over the last decade, he has provided mobility solutions for numerous Fortune 100 organizations. Ben is passionate about cross-platform development, particularly the use of Titanium mobile for mobile app development. He was an early adopter of the Titanium mobile SDK and has built apps since the earliest previews of Appcelerator's mobile platform. Ben is an active member of the mobile development community and holds a Titanium certification in addition to being part of the Appcelerator Titan evangelist group. A strong advocate and contributor to the Titanium module ecosystem, Ben has published numerous open source modules used in thousands of published apps. An active blogger at bencoding.com, he frequently posts tutorials on mobile development and enterprise coding topics. I would like to thank my family, friends, and co-workers for their enthusiasm and encouragement. Without their support, this book would not have been possible. I would also like to thank the Titanium community for providing a thriving environment to learn, create, and develop within. www.it-ebooks.info About the Reviewers David Bankier leads YY Digital, a company that builds integrated mobile, tablet, and server-side applications for enterprise. Previously, David worked in the telecommunications industry with a strong focus on VoIP technologies. He has used Titanium for mobile development since 2010 and uses a mix of Node, Scala, and Java on the backend. David is also the creator of TiShadow, the popular open source project for rapid Titanium development. As a Titan, David's blog http://www.yydigital.com/blog dives deep into Titanium. Imraan Jhetam is a medical doctor and entrepreneur living in England with equal loves for both medical law and technology. He earned his Medical Degree from the University of Natal in 1983, his MBA from the University of Witwatersrand and a Masters of Law Degree from Cardiff University. Imraan has been fascinated by computers since his youth and taught himself the basics of programming during his university years. He has been writing programs since the mid 1970's in various languages and for different platforms and has fond memories of his first Apple IIe with its then impressive 64 KB RAM. When he is not busy seeing patients or writing medico-legal reports, he spends his time developing applications and developed Snappa, a social-sharing game that is the better way to draw something for friends. This was written using the incredible Titanium Studio tools and Appcelerator Cloud Services and is now in the Apple and Android App Stores. He was also third prize winner at the first Codestrong Hackathon with two e-payment apps PayBill and PayPad, that also included social media, geolocation, photos, and bar-codes, and which were developed in a restricted and short time using Appcelerator Titanium Studio. You can contact Imraan via www.snappa.mobi or via Twitter @The__i. www.it-ebooks.info 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. 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. www.it-ebooks.info Table of Contents Preface 1 Chapter 1: Patterns and Platform Tools 7 Introduction 7 Defining an app namespace 10 CommonJS in practice 10 Using platform indicators 19 Global logging using Ti.App.Listener 27 Chapter 2: Cross-platform UI 33 Introduction 33 Cross-platform HUD progress indicator 34 In-app notifications 38 Screen Break Menu 44 Metro Style Tab Control 49 Slideout Menu 53 Chapter 3: Using Databases and Managing Files 63 Introduction 63 Accessing your database's Ti.Filesystem 64 DbTableChecker SQLite table existence checking 69 Recursively handling files using Dossier 74 Tuning your SQLite database for maximum performance 77 Data access using DbLazyProvider 83 NoSQL using MongloDb 87 Chapter 4: Interacting with Web Services 93 Introduction 93 Consuming RSS feeds 94 Creating a business location map using Yahoo Local 101 Using Google Analytics in your app 106 www.it-ebooks.info Table of Contents Making SOAP service calls using SUDS.js 111 Using the LinkedIn Contacts API 117 Chapter 5: Charting and Documents 127 Introduction 127 Opening PDF documents 128 Using an iPad for document signatures 134 Creating PDF documents from images or screenshots 140 Generating PDF documents using jsPDF 144 Creating a scheduling chart using RGraph 148 Displaying information with Google gauges 154 Chapter 6: Using Location Services 159 Introduction 159 Native geolocation using basicGeo 160 Using the Ti.GeoProviders framework for geolocation 168 Multitenant geolocation 176 Calculating distance between addresses 181 Background geolocation management 188 Chapter 7: Threads, Queues, and Message Passing 197 Introduction 197 Queuing multiple downloads 198 Launching one app from another 206 Cross-platform URL schemes 214 Opening your Android app with BOOT_COMPLETED 224 iOS Multithreading using Web Workers 233 Chapter 8: Basic Security Approaches 239 Introduction 239 Implementing iOS data protection in Titanium 240 AES encryption using JavaScript 246 Basic authentication using Ti.Network.HTTPClient 252 Implementing a cross-platform passcode screen 257 Working with protected ZIP files on iOS 262 Chapter 9: App Security Using Encryption and Other Techniques 269 Introduction 269 Using secure properties 270 Object and string encryption 277 Working with encrypted files 281 Handling protected PDFs on iOS 286 Android lock screen monitor 292 ii www.it-ebooks.info Table of Contents Appendix: Titanium Resources 297 Getting started with Titanium 297 Getting started with Android 298 Getting started with iOS 298 Titanium testing resources 298 Modules and open source 299 Titanium community links 300 Index 303 iii www.it-ebooks.info
Description: