You are previewing Appcelerator Titanium Business Application Development Cookbook.
O'Reilly logo
Appcelerator Titanium Business Application Development Cookbook

Book Description

Over 40 hands-on recipes to quickly and efficiently create business grade Titanium Enterprise apps

  • Provide mobile solutions to meet the challenges of today’s Enterprise mobility needs

  • Study the best practices in security, document management, and Titanium Enterprise Development

  • Create cross-platform Enterprise class Titanium apps quickly and efficiently with step-by-step instructions and images to help guide you

In Detail

The demand for Mobile in the Enterprise has never been greater. While meeting this demand is becoming increasingly business critical, the complexities of development are amplified by the explosion in the number and variety of devices and platforms. Appcelerator's Titanium Mobile Platform stands out for its rapid development speed, large number of APIs, and focus on providing a native experience. This ability to rapidly provide business value in a cross-platform way makes Titanium a compelling platform for the creation of Enterprise applications.

Appcelerator Titanium Business Application Development Cookbook is your complete guide to creating business applications. From building a unique user experience to securing your application, this book covers every aspect of business application development.

Beginning with a discussion of design patterns, the practical recipes in this cookbook progress through different topics required for Enterprise cross-platform mobile development. Each recipe is a self-contained lesson that can be used in creating apps for your organization. With Appcelerator Titanium Business Application Development Cookbook learn how to work with data on the device, create charts and graphs, and interact with various web services. Later recipes discussing application security and native module development help provide additional resources to accelerate your next Titanium mobile development project.

Table of Contents

  1. Appcelerator Titanium Business Application Development Cookbook
    1. Table of Contents
    2. Appcelerator Titanium Business Application Development Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Patterns and Platform Tools
      1. Introduction
        1. Introducing Titanium
        2. Architecture of Titanium
        3. Building a Cross-platform
      2. Defining an app namespace
        1. How to do it...
      3. CommonJS in practice
        1. Getting ready
        2. How to do it...
          1. Creating the project's app.js
          2. Building the datehelpers module
          3. The dateWin module
        3. How it works...
          1. Require
          2. Properties
          3. Functions
          4. Instance object using module.exports
          5. CommonJS global scope anti-pattern
        4. See also
      4. Using platform indicators
        1. Getting ready
          1. Adding recipe components to your project
        2. How to do it...
        3. How it works...
          1. Simulator check
          2. Background capabilities
            1. Detecting tablets
            2. A 4-inch iPhone
            3. iPad
            4. iPad Mini
      5. Global logging using Ti.App.Listener
        1. Getting ready
        2. How to do it...
          1. Designing global logging using events
            1. Defining our app.js
            2. The logging module
          2. Bringing it all together
            1. Window and module variable setup
            2. Firing the application-level event
        3. There's more...
    9. 2. Cross-platform UI
      1. Introduction
      2. Cross-platform HUD progress indicator
        1. Getting ready
          1. Adding the HUD module to your project
          2. Creating a sample window
          3. Adding HUD listeners
            1. Creating a HUD indicator
            2. Updating the HUD message
            3. Closing the HUD window
        2. How it works…
      3. In-app notifications
        1. Getting ready
          1. Adding the NotifyUI module to your project
        2. How to do it…
          1. Creating a sample window
          2. Adding NotifyUI listeners
          3. Showing a message window
            1. Updating a message
          4. Closing a message window
        3. How it works…
          1. Built-in message styles
      4. Screen Break Menu
        1. Getting ready
          1. Menu when closed
          2. The menu, when opened
          3. Adding the Screen Break Menu to your project
        2. How to do it…
          1. Creating the sample window
          2. Adding Screen Break Menu listeners
          3. Creating a notes menu object
          4. Showing the menu
      5. Metro Style Tab Control
        1. Getting ready
          1. Adding the Tab Control to your project
        2. How to do it…
          1. Creating a sample window
          2. Creating the settings object
          3. Defining tabs
          4. Adding Tab Control to the window
          5. Adding tab listeners
      6. Slideout Menu
        1. Getting ready
          1. Installing the Ti.Draggable module
          2. Adding the Slideout Menu module to your project
        2. How to do it…
          1. Defining our content views
          2. Building our menu items
          3. Opening the app window
          4. Adding menu listeners
          5. Adding custom application listeners
        3. How it works…
          1. Creating the menu
          2. Opening the menu container
          3. Showing the menu
          4. Toggling the menu
          5. Closing the menu
          6. Determining menu state
          7. Accessing the current view
          8. Closing the menu container
          9. Using the sample's Global Events
        4. See also
    10. 3. Using Databases and Managing Files
      1. Introduction
      2. Accessing your database's Ti.Filesystem
        1. Getting ready
        2. How to do it…
          1. Finding our database Ti.Filesystem.File
          2. Determining the database directory
          3. File exist check
          4. RemoteBackup – iOS-specific attribute
          5. Renaming a database file
          6. Listing all databases
          7. Removing a database file
        3. How it works…
          1. Setting up our test
          2. Finding our database Ti.Filesystem
          3. Determining database directory
          4. File exist check
          5. Renaming a database file
          6. Listing all databases
          7. Removing a database file
      3. DbTableChecker SQLite table existence checking
        1. Getting ready
        2. How to do it…
          1. Creating our module
          2. Namespace and app setup
          3. Creating our window
          4. Testing if a table exists
          5. Creating a table
          6. Removing a table
        3. How it works…
          1. Testing helpers
          2. The tableExists method
      4. Recursively handling files using Dossier
        1. Getting ready
          1. Adding the Dossier module into your project
        2. How to do it…
          1. Creating sample directories
          2. Recursive listing of directory contents
          3. Recursively copying directory contents
          4. Recursively moving directory contents
        3. See also
      5. Tuning your SQLite database for maximum performance
        1. Getting ready
          1. Adding the TimeLogger module
        2. How to do it…
          1. Creating our testing Interface
          2. Benchmarking
        3. How it works…
          1. Database setup
          2. Performing the tests
        4. See also
      6. Data access using DbLazyProvider
        1. Getting ready
        2. How to do it…
          1. Creating our testing Interface
          2. Lazy-loading using transactions
          3. Creating a select statement using lazy-loading
        3. How it works…
          1. Creating a new DbLazyProvider object
          2. Getting a connection object
          3. Beginning a transaction
          4. Ending a transaction
          5. Opening a database connection
          6. Closing a database connection
      7. NoSQL using MongloDb
        1. Getting ready
        2. How to do it…
          1. Initializing your database
          2. Adding the Titanium storage provider
          3. Initializing our collection
          4. Using events
          5. Inserting documents
          6. Using find to query
          7. Updating documents
          8. Using findOne to query for a single document
          9. Removing documents
        3. See also
    11. 4. Interacting with Web Services
      1. Introduction
      2. Consuming RSS feeds
        1. Getting ready
        2. How to do it…
          1. Creating a UI for the sample app
          2. Reading an RSS feed with YQL
          3. Reading an RSS feed with XML parsing
          4. Displaying the articles
        3. How it works…
          1. Using the yqlQuery function
          2. Using the query function
        4. See also
      3. Creating a business location map using Yahoo Local
        1. Getting ready
        2. How to do it…
          1. Adding your API key
          2. Creating a UI for the sample app
          3. Updating the map
          4. Searching
        3. How it works…
          1. Using addAPIKey to your Yahoo service key
          2. Using the geoQuery method
          3. Using the currentLocationQuery method
      4. Using Google Analytics in your app
        1. Getting ready
        2. How to do it…
          1. Creating an instance of the module
          2. Helper functions
          3. Start recording events
          4. Creating our sample UI
          5. Recording an action
          6. The Pageview function on opening a window
          7. The Pageview function on a child window
        3. See also
      5. Making SOAP service calls using SUDS.js
        1. Getting ready
        2. How to do it…
          1. SOAP helper methods
          2. Creating the UI
          3. The uiHelpers object
          4. Calling the SOAP service
        3. See also
      6. Using the LinkedIn Contacts API
        1. Getting ready
        2. How to do it…
          1. Adding your API key and secret key
          2. Adding permissions
          3. Creating the UI
          4. Loading your LinkedIn contacts
          5. Using the uiHelpers object to format results
          6. Parsing the LinkedIn API results
        3. See also
    12. 5. Charting and Documents
      1. Introduction
      2. Opening PDF documents
        1. Getting ready
        2. How to do it…
          1. Creating a link to the PDF file
          2. Creating our example UI
          3. Opening a PDF file on the click of a button
          4. Opening a PDF file within your iOS app
          5. File clean-up on closing a window
        3. See also
      3. Using an iPad for document signatures
        1. Getting ready
        2. How to do it…
          1. Creating a window for the recipe
          2. Adding a document view
          3. Adding a signature view
          4. Adding buttons
          5. Reloading a saved signature
        3. See also
      4. Creating PDF documents from images or screenshots
        1. Getting ready
        2. How to do it…
          1. Creating a UI for the recipe
          2. Creating a PDF from a view
          3. Creating a PDF document from a screenshot
        3. See also
      5. Generating PDF documents using jsPDF
        1. Getting ready
        2. How to do it…
          1. Creating a UI for the recipe
          2. Creating a PDF document using jsPDF
        3. See also
      6. Creating a scheduling chart using RGraph
        1. Getting ready
        2. How to do it…
          1. Creating a UI for the recipe
          2. Creating schedules and assigning tasks
          3. Launching the example
        3. How it works…
        4. See also
      7. Displaying information with Google gauges
        1. Getting ready
        2. How to do it…
          1. Loading saved sales information
          2. Creating a UI for the recipe
          3. Adjusting sales
          4. Reloading saved sales
        3. See also
    13. 6. Using Location Services
      1. Introduction
      2. Native geolocation using basicGeo
        1. Getting ready
        2. How to do it...
          1. Adding availability helpers
          2. Adding the location services purpose
          3. Building the recipe UI
          4. Working with place objects
          5. Finding current location
          6. Forward location lookup
          7. Device capability check
        3. See also
      3. Using the Ti.GeoProviders framework for geolocation
        1. Getting ready
        2. How to do it...
          1. Adding your API key
          2. Adding your purpose
          3. Building the recipe UI
          4. Running the reverse geolocation
          5. Lookup functions
        3. See also
      4. Multitenant geolocation
        1. Getting ready
        2. How to do it...
          1. Adding providers
          2. Adding your purpose
          3. Building the recipe UI
          4. Lookup helper methods
          5. Performing a multitenant reverse geolocation lookup
      5. Calculating distance between addresses
        1. Getting ready
        2. How to do it...
          1. Adding address information
          2. Building the recipe UI
          3. Distance and address methods
          4. Finding the distance between the two addresses
      6. Background geolocation management
        1. Getting ready
          1. Updating your tiapp.xml file
        2. How to do it...
          1. Namespace and app setup
          2. Background location options
          3. Building the recipe's UI
          4. The recipe's assistant methods
          5. Geolocation events
          6. Background button events
          7. iOS app-level events
        3. See also
    14. 7. Threads, Queues, and Message Passing
      1. Introduction
      2. Queuing multiple downloads
        1. Getting ready
          1. Network connection
        2. How to do it...
          1. Creating the recipe's UI
          2. Creating a queue
          3. Adding jobs to the queue
          4. Recipe's assistant functions
          5. Start downloading
        3. See also
      3. Launching one app from another
        1. Getting ready
          1. Network connection
        2. How to do it...
          1. iOS updating tiapp.xml
          2. Creating an app launch list
            1. iOS scheme list
            2. Android scheme list
          3. The recipe's UI
        3. See also
      4. Cross-platform URL schemes
        1. Getting ready
          1. AppLauncher requirement
        2. How to do it...
          1. iOS updating tiapp.xml
          2. Android updating tiapp.xml
          3. Creating the recipe UI
          4. Launching helper functions
          5. When launched from another app
        3. How it works...
          1. Launching the About window
          2. Launching the Login window
      5. Opening your Android app with BOOT_COMPLETED
        1. Getting ready
        2. How to do it...
          1. Required tiapp.xml updates
          2. Scenario A – auto restart
            1. Auto restart step 1: adding the receiver to tiapp.xml
            2. Auto restart step 2: testing
          3. Scenario B – notification on restart
            1. Notification on restart step 1: adding receiver to tiapp.xml
            2. Notification on restart step 2: testing
          4. Scenario C – property controlled
            1. Property controlled step 1: adding receiver to tiapp.xml
            2. Property controlled step 2: create recipe app.js
            3. Property controlled step 3: testing
        3. See also
      6. iOS Multithreading using Web Workers
        1. Getting ready
        2. How to do it...
          1. Creating the recipe UI
          2. Testing functions
          3. Multithreading using Web Workers
        3. See also
    15. 8. Basic Security Approaches
      1. Introduction
      2. Implementing iOS data protection in Titanium
        1. Getting ready
          1. Enabling data protection
          2. iOS device browser
        2. How to do it...
          1. Creating the namespace and imports
          2. Creating the recipe UI
          3. Creating a file to verify data protection
        3. How it works...
      3. AES encryption using JavaScript
        1. Getting ready
        2. How to do it...
          1. Creating the recipe UI
          2. Encrypting and decrypting values
        3. See also
      4. Basic authentication using Ti.Network.HTTPClient
        1. Getting ready
        2. How to do it...
          1. Creating the recipe UI
          2. Creating a service connection
      5. Implementing a cross-platform passcode screen
        1. Getting ready
        2. How to do it...
          1. Creating the recipe UI
          2. Launching the passcode screen
        3. See also
      6. Working with protected ZIP files on iOS
        1. Getting ready
        2. How to do it...
          1. Creating the recipe UI
          2. Creating a password-protected ZIP file
          3. Unzipping a protected ZIP file
        3. See also
    16. 9. App Security Using Encryption and Other Techniques
      1. Introduction
      2. Using secure properties
        1. Getting ready
          1. Adding the module reference
        2. How to do it...
          1. Creating the namespace
          2. Creating the secure properties object
          3. Result comparison helper
          4. Reading secure properties without defaults
          5. Reading secure properties with defaults
          6. Setting secure property values
          7. Listing secure property field names
          8. Removing secure properties
          9. Check if a secure property exists
        3. How it works...
          1. Secure properties on iOS
          2. Secure properties on Android
          3. Secure property considerations
        4. See also
      3. Object and string encryption
        1. Getting ready
        2. How to do it...
          1. Creating the namespace
          2. Generating keys
            1. Generating a derived key
            2. Generating a random key
            3. Creating the stringCrypto object
          3. Using DES encryption
          4. Encrypting using DES
          5. Decrypting using DES
          6. Encrypting using AES
          7. Decrypting using AES
          8. Titanium object encryption
        3. See also
      4. Working with encrypted files
        1. Getting ready
        2. How to do it...
          1. Creating the UI
          2. Encrypting a file
          3. Decrypting a file
        3. See also
      5. Handling protected PDFs on iOS
        1. Getting ready
        2. How to do it...
          1. Creating the recipe's UI
          2. Protecting a PDF file
          3. Unlocking a PDF file
        3. See also
      6. Android lock screen monitor
        1. Getting ready
        2. How to do it...
          1. Creating the recipe's UI
          2. Verifying if the lock pattern is enabled
          3. Creating a Lock Helper
          4. Screen lock events
          5. Using window focus for monitoring
          6. Stop monitoring
        3. See also
    17. A. Titanium Resources
      1. Getting started with Titanium
      2. Getting started with Android
      3. Getting started with iOS
      4. Titanium testing resources
        1. TiShadow
        2. Titanium-Jasmine
        3. TiJasmine
      5. Modules and open source
        1. Appcelerator on Github
        2. Titanium mobile on Github
        3. Titanium modules on Github
      6. Titanium community links
        1. Documentation
        2. Support
        3. Other helpful resources
    18. Index