SlideShare a Scribd company logo
1 of 59
Building Native Cross-Platform
      Mobile Applications
                           Rob Rusher
        Twitter: @robrusher | http://robrusher.com



                         More Information:
     Twitter: @appcelerator | http://appcelerator.com


         http://www.on3solutions.com | Yeah, I built an app for that!   1
Why listen to me
Rob Rusher
Principal Consultant

   •Rich Client Application Team Mentor
   •Mobile Application Architect
   •Adobe Technologies Expert




               http://www.on3solutions.com | Elements to grow from within   2
About this Session




http://www.on3solutions.com | Elements to grow from within   3
About this Session
• The Good, the Bad and the Ugly




           http://www.on3solutions.com | Elements to grow from within   3
About this Session
• The Good, the Bad and the Ugly
• An alternative
 •Titanium Mobile
 •API Overview




           http://www.on3solutions.com | Elements to grow from within   3
About this Session
• The Good, the Bad and the Ugly
• An alternative
 •Titanium Mobile
 •API Overview
• Example App




           http://www.on3solutions.com | Elements to grow from within   3
The Good
• The Apps!




              http://www.on3solutions.com | Elements to grow from within   4
The Bad
• Xcode and Interface Builder




           http://www.on3solutions.com | Elements to grow from within   5
And the ugly
• The worst thing about iPhone development
          • Objective-C
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
   UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil]
autorelease];

    cell.text = [photoNames objectAtIndex:indexPath.row];

    NSData *imageData = [NSData dataWithContentsOfURL:[photoURLs objectAtIndex:indexPath.row]];
    cell.image = [UIImage imageWithData:imageData];

    return cell;
}


• Seriously?!

                           http://www.on3solutions.com | Elements to grow from within                6
Reality sets in...
How do you target all these
        platforms




     http://www.on3solutions.com | Yeah, I built an app for that!   7
Reality sets in...
How do you target all these
        platforms
    Build them all separately




     http://www.on3solutions.com | Yeah, I built an app for that!   7
Reality sets in...
How do you target all these
        platforms
    Build them all separately
      Web Browser version


     http://www.on3solutions.com | Yeah, I built an app for that!   7
Reality sets in...
How do you target all these
        platforms
    Build them all separately
       Web Browser version
   Write once, suck everywhere

      http://www.on3solutions.com | Yeah, I built an app for that!   7
Our Requirements




http://www.on3solutions.com | Elements to grow from within   8
Our Requirements
• Target multiple platforms from a single codebase




            http://www.on3solutions.com | Elements to grow from within   8
Our Requirements
• Target multiple platforms from a single codebase
• Apps must feel like they belong on the platform




            http://www.on3solutions.com | Elements to grow from within   8
Our Requirements
• Target multiple platforms from a single codebase
• Apps must feel like they belong on the platform
• Apps need to perform like native




            http://www.on3solutions.com | Elements to grow from within   8
Our Requirements
• Target multiple platforms from a single codebase
• Apps must feel like they belong on the platform
• Apps need to perform like native
• Bonus: Open source and extensible




            http://www.on3solutions.com | Elements to grow from within   8
Our Requirements
• Target multiple platforms from a single codebase
• Apps must feel like they belong on the platform
• Apps need to perform like native
• Bonus: Open source and extensible
• Bonus: Use skills we already have




            http://www.on3solutions.com | Elements to grow from within   8
A Solution
• Titanium Mobile
 • JavaScript library for building native applications
• Open Source (Apache 2.0 License)
• Mobile Platforms
 • iPhone, Android, Blackberry, webOS (soon)
• Desktop Platforms
 • Win32, Mac, Linux
• Website: http://appcelerator.com

            http://www.on3solutions.com | Elements to grow from within   9
Why Titanium Mobile?
• Build Native Apps (not WebKit apps)
 • Responsive
 • Leverage Device Capabilities
• Use Web Technologies
 • Common Skill Set
 • Very Fast Development
 • No Objective-C
• Best of both worlds
• One set of technologies, many platforms
            http://www.on3solutions.com | Elements to grow from within   10
Titanium Mobile – Architecture

UI API contains mappings to native
UI components                                                                   Application Source Files
• Navbar, Tabbar, Toolbar, Menus                                              (HTML, CSS, and JavaScript)
• Dialogs, Alerts, Buttons

Phone API contains mappings to native
phone capabilities
• Geo, Accelerometer, Maps, Sound
• Database, File System, Network




           Your Application                                                                Your Application

       UI API          Phone API                                                     UI API             Phone API

   JavaScript - Objective-C Bridge                                                   JavaScript - Java Bridge

        iPhone Objective-C API                                                             Android Java API



      Native iPhone App                                                             Native Android App
                              http://www.on3solutions.com | Elements to grow from within
Titanium Features
Native UI                                                   Rich Media APIs
Real native tables, tabs, sliders,                          Local and streaming audio and
and views                                                   video, media recording



Location APIs                                               Open Source and Extensible
Native Maps, Compass, and                                   Extend Titanium with custom
Geolocation                                                 modules in native code



Local and Remote Data                                       Integrated Analytics
Local SQL Database, Lightweight                             Baked-in analytics APIs to measure
Key/Value Store, XHR                                        results and behavior



Social APIs                                                 Development Tools
Integrated Facebook Connect                                 Develop and distribute your app for
and YQL                                                     multiple platforms from a single tool


            http://www.on3solutions.com | Elements to grow from within                      12
What its not
• Not a native wrapper around a web view
  (PhoneGap being an example of this approach)
• However, you do have a web view component for
  HTML/CSS UI if that is your preference
• Your JavaScript code is invoking native APIs for
  UI and other native functions
• Think MacRuby/Hot Cocoa on the desktop or
  some AAA mobile games which ship with a Lua
  interpreter

            http://www.on3solutions.com | Elements to grow from within   13
Example




http://www.on3solutions.com | Elements to grow from within   14
Example




http://www.on3solutions.com | Elements to grow from within   15
Example




http://www.on3solutions.com | Elements to grow from within   16
Titanium Developer
• Manage and run Titanium
  applications
• Package applications for
  distribution
• Run on a device for
  testing
• Manage Appcelerator
  account


            http://www.on3solutions.com | Elements to grow from within   17
Getting started
• Project created/managed via Titanium
  Developer
• Titanium Developer
 • deploys code to simulators
 • helps with testing and packaging for devices
• Requires sign-up for Appcelerator Network
  (support, e-mail list, other services)



            http://www.on3solutions.com | Elements to grow from within   18
Getting started
• Project created/managed via Titanium
  Developer
• Titanium Developer
 • deploys code to simulators
 • helps with testing and packaging for devices
• Requires sign-up for Appcelerator Network
  (support, e-mail list, other services)
                Its FREE (as in beer!)

            http://www.on3solutions.com | Elements to grow from within   18
Hello World
• Prerequisites
 • iPhone and/or Android SDK
 • Titanium Developer
• Your First Project
 •Creating a mobile project
 •Mobile project structure
 •Editing code, adding UI widgets to the app
 •Deploy to simulator


            http://www.on3solutions.com | Elements to grow from within   19
KitchenSink
• Example Code
• Living Reference Document
• Demonstrates API coverage




            http://www.on3solutions.com | Elements to grow from within   20
Titanium Fundamentals
• Titanium application is a
  JavaScript program that is
  interpreted at runtime on the
  device
• app.js defines the root
  execution context of the app
• Note: not running in a browser
• It uses the WebKit KJS
  JavaScript engine (iOS) or
  Rhino (Android/BB)
            http://www.on3solutions.com | Elements to grow from within   21
How it works
• Titanium takes the Javascript code
  •Analyzes and preprocesses it
  •Pre-compiles it into a set of symbols
  •Symbols are resolved based on your applications uses
    of the Titanium APIs
• From this symbol hierarchy
  •Build a symbol dependency matrix that maps to the
    underlying Titanium library symbols
  •Understand which APIs specifically your app needs
• Compiled almost one to one into the representative
  symbols in native-land

              http://www.on3solutions.com | Elements to grow from within   22
Scripts and Stylesheets
• Organized into logical namespaces
• “Titanium” (or just “Ti” for short) is the root
  namespace for all Titanium functionality
• A few other odds and ends in the global space
  – setTimeout/setInterval
  – alert
  – JSON




              http://www.on3solutions.com | Elements to grow from within   23
Design the UI
                                               • A single window
                                                 or stack of
                                                 windows
                                               • Tab Group
                                                 containing many
                                                 windows
                                               • Windows contain
                                                 views


http://www.on3solutions.com | Elements to grow from within    24
Windows and Context
• Windows are the top level container for Titanium
  applications
• Applications usually consist of one window or
  several windows in a tab group
• Windows usually create new execution contexts
   •Execution context == A unique JavaScript symbol
    space
• Such windows are “Heavyweight” windows
• Can also create “Lightweight” windows (for apps
  that run in a single context)

             http://www.on3solutions.com | Elements to grow from within   25
Demo Contexts
• New Project - Two Tabs with “Lightweight”
  windows
• Switch to contain urls and contexts
• Symbols not defined in other contexts




            http://www.on3solutions.com | Elements to grow from within   26
View Hierarchy
• Views are the building blocks of
  Titanium UIs
  – Specialized views: table views,
   image views, map views, etc.
• Views can contain child views,
  which are positioned relative to
  the parent
• Layout Options: Absolute,
  vertical, or horizontal (currently
  iPhone only)
• Vertical layouts require height to
  be set
                http://www.on3solutions.com | Elements to grow from within   27
Custom Events
• Use for cross-context messaging
• Events are received across all ACTIVE contexts
• Windows not yet open do not receive events
• Use also as an inversion of control mechanism
  – Publish message when the database has been updated
  – Publish message when contacting a server
  – Using pub/sub messaging is very useful in a
   component-oriented framework like Titanium



             http://www.on3solutions.com | Elements to grow from within   28
Demo: Events
• Now lets use custom events in our new app
• Events can have a data payload
• Remember that events are only received in
  active contexts




            http://www.on3solutions.com | Elements to grow from within   29
Cross Platform
• Not all UI is available across platforms
• Titanium != Write Once, Run Everywhere
• It tries to enable native apps that look and feel
  like they were created in Objective-C or Java
• Also note that even cross-platform UI
  components (like table views) will render
  differently cross platform
• Cross Platform testing is critical during
  development cycle

             http://www.on3solutions.com | Elements to grow from within   30
Cross Platform Tips
• iPhone/Android
  subdirectories
• Ti.Platform.osname
• Display height/width
• OS version
• Check Out Kitchen
  Sink Platform
  example



          http://www.on3solutions.com | Elements to grow from within   31
Build an Example
• App Features:
 –   Multiple Window/Tabbed UI
 –   Properties API
 –   Camera and Local Photo Gallery
 –   Upload to remote web service (TwitPic)
• Want to develop and deploy to a device in the
  space of a few minutes




               http://www.on3solutions.com | Elements to grow from within   32
iPhone SDK Users
• Will need to download build to address iOS 4
  issues that is not in basic 1.3.0 release
• Nightly Builds:
  – http://builds.appcelerator.com.s3.amazonaws.com/index.html

• Let’s go through install of “latest and greatest”
  build...




                  http://www.on3solutions.com | Elements to grow from within   33
OhSnap!

• New Project via
  Titanium Developer
• Grab new icons
  from Glyphish
• Configure tab icons,
  new windows/
  execution contexts



             http://www.on3solutions.com | Elements to grow from within   34
1. Gather UI

• Create necessary
  buttons, image
  placeholders, text
  labels
• Arrange using
  vertical layout
• Check out styling
  options


             http://www.on3solutions.com | Elements to grow from within   35
2. Login Screen

• Pre-populate text
  fields with
  Properties
• Persist un/pw
  combo
• Add event listener
  to save button



             http://www.on3solutions.com | Elements to grow from within   36
3. Media


• Open Photo Gallery
• Show Camera
• Dynamically update
  ImageView source
  file



            http://www.on3solutions.com | Elements to grow from within   37
4. Upload Image


• Create HTTPClient
  object
• Open a POST
  request
• Upload image media
  and Twitter update



            http://www.on3solutions.com | Elements to grow from within   38
Deploy
• Demo: Deploy via Titanium Developer
• On your own, provision your system for
  development on device
• Android == super easy
• iPhone... not so much
• Video Tutorial:
  – http://vimeo.com/10278960
• All Appcelerator Videos:
  – http://vimeo.com/appcelerator

             http://www.on3solutions.com | Elements to grow from within   39
Recap OhSnap!
• < 200 Lines of code
• Persistent App Preferences
• Fully native UI (ugly, but see Snapost for the
  pretty...)
• Integrated camera/photo gallery
• XML HTTP Request upload to remote server
• 100% Cross-Platform



             http://www.on3solutions.com | Elements to grow from within   40
Next Steps




http://www.on3solutions.com | Elements to grow from within   41
Next Steps
• Deploy to device




           http://www.on3solutions.com | Elements to grow from within   41
Next Steps
• Deploy to device
• Submit to market




           http://www.on3solutions.com | Elements to grow from within   41
Next Steps
• Deploy to device
• Submit to market
• Make (or save) your
  company millions!




           http://www.on3solutions.com | Elements to grow from within   41
Next Steps
• Deploy to device
• Submit to market
• Make (or save) your
  company millions!
• Buy me a Bookers -->




           http://www.on3solutions.com | Elements to grow from within   41
Thank you
• On3                                                          Grow
                                                                Your Own
 • Consulting, Mentoring, Training Flex Team
 • http://www.on3solutions.com
 •Twitter: on3solutions
                                                               Tired of IT outsourcing?
                                                               Cultivate expertise from within with the help

• Rob Rusher
                                                               of On3. We mentor development teams
                                                               through the process of implementing,
                                                               developing and mastering next-generation

 • http://www.robrusher.com                                    technologies. We also o er traditional needs
                                                               assessment and e ective instruction. Call On3,
                                                               and prepare to watch your capabilities grow.
 •Twitter: robrusher                                                                 On3 Solutions
                                                                             sales@on3solutions.com      3
                                                                              www.on3solutions.com
                                                                                       877.885.7044
                                                                                       303.885.7044
                                                                                                      On

            http://www.on3solutions.com | Elements to grow from within                                       42
Resources
• Get Titanium Mobile
 • http://www.appcelerator.com
• Titanium Reference
 • http://www.codestrong.com
• Kevin Whinnery
 • http://kevinwhinnery.com
• Code for this presentation
 • http://github.com/kwhinnery


            http://www.on3solutions.com | Elements to grow from within   43

More Related Content

Viewers also liked

Create Real Interactive Prototypes in Minutes
Create Real Interactive Prototypes in MinutesCreate Real Interactive Prototypes in Minutes
Create Real Interactive Prototypes in Minutes
Rob Rusher
 
Teori pemerolehan bahasa pertama
Teori pemerolehan bahasa pertamaTeori pemerolehan bahasa pertama
Teori pemerolehan bahasa pertama
Phyne Phain
 

Viewers also liked (11)

Create Real Interactive Prototypes in Minutes
Create Real Interactive Prototypes in MinutesCreate Real Interactive Prototypes in Minutes
Create Real Interactive Prototypes in Minutes
 
Numbers 0 9_ (1)
Numbers 0 9_ (1)Numbers 0 9_ (1)
Numbers 0 9_ (1)
 
Awea Regional Wind Energy Summit
Awea Regional Wind Energy SummitAwea Regional Wind Energy Summit
Awea Regional Wind Energy Summit
 
Addressing Fall Protection Anchorages
Addressing Fall Protection AnchoragesAddressing Fall Protection Anchorages
Addressing Fall Protection Anchorages
 
OSHA Proposed Fall Protection Regulations: Latest Developments
OSHA Proposed Fall Protection Regulations: Latest DevelopmentsOSHA Proposed Fall Protection Regulations: Latest Developments
OSHA Proposed Fall Protection Regulations: Latest Developments
 
Flex Component Life Cycle
Flex Component Life CycleFlex Component Life Cycle
Flex Component Life Cycle
 
Definition of Paid Media and more
Definition of Paid Media and moreDefinition of Paid Media and more
Definition of Paid Media and more
 
Teori pemerolehan bahasa pertama
Teori pemerolehan bahasa pertamaTeori pemerolehan bahasa pertama
Teori pemerolehan bahasa pertama
 
Overview of Proposed Changes to OSHA 1910 General Industry Regulations
Overview of Proposed Changes to OSHA 1910 General Industry RegulationsOverview of Proposed Changes to OSHA 1910 General Industry Regulations
Overview of Proposed Changes to OSHA 1910 General Industry Regulations
 
The Value of Fall Hazard Risk Assessments
The Value of Fall Hazard Risk AssessmentsThe Value of Fall Hazard Risk Assessments
The Value of Fall Hazard Risk Assessments
 
Impact of ANSI Standards on Fall Protection Equipment Purchase
Impact of ANSI Standards on Fall Protection Equipment PurchaseImpact of ANSI Standards on Fall Protection Equipment Purchase
Impact of ANSI Standards on Fall Protection Equipment Purchase
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Building Native Cross Platform Mobile Applications

  • 1. Building Native Cross-Platform Mobile Applications Rob Rusher Twitter: @robrusher | http://robrusher.com More Information: Twitter: @appcelerator | http://appcelerator.com http://www.on3solutions.com | Yeah, I built an app for that! 1
  • 2. Why listen to me Rob Rusher Principal Consultant •Rich Client Application Team Mentor •Mobile Application Architect •Adobe Technologies Expert http://www.on3solutions.com | Elements to grow from within 2
  • 3. About this Session http://www.on3solutions.com | Elements to grow from within 3
  • 4. About this Session • The Good, the Bad and the Ugly http://www.on3solutions.com | Elements to grow from within 3
  • 5. About this Session • The Good, the Bad and the Ugly • An alternative •Titanium Mobile •API Overview http://www.on3solutions.com | Elements to grow from within 3
  • 6. About this Session • The Good, the Bad and the Ugly • An alternative •Titanium Mobile •API Overview • Example App http://www.on3solutions.com | Elements to grow from within 3
  • 7. The Good • The Apps! http://www.on3solutions.com | Elements to grow from within 4
  • 8. The Bad • Xcode and Interface Builder http://www.on3solutions.com | Elements to grow from within 5
  • 9. And the ugly • The worst thing about iPhone development • Objective-C - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease]; cell.text = [photoNames objectAtIndex:indexPath.row]; NSData *imageData = [NSData dataWithContentsOfURL:[photoURLs objectAtIndex:indexPath.row]]; cell.image = [UIImage imageWithData:imageData]; return cell; } • Seriously?! http://www.on3solutions.com | Elements to grow from within 6
  • 10. Reality sets in... How do you target all these platforms http://www.on3solutions.com | Yeah, I built an app for that! 7
  • 11. Reality sets in... How do you target all these platforms Build them all separately http://www.on3solutions.com | Yeah, I built an app for that! 7
  • 12. Reality sets in... How do you target all these platforms Build them all separately Web Browser version http://www.on3solutions.com | Yeah, I built an app for that! 7
  • 13. Reality sets in... How do you target all these platforms Build them all separately Web Browser version Write once, suck everywhere http://www.on3solutions.com | Yeah, I built an app for that! 7
  • 14. Our Requirements http://www.on3solutions.com | Elements to grow from within 8
  • 15. Our Requirements • Target multiple platforms from a single codebase http://www.on3solutions.com | Elements to grow from within 8
  • 16. Our Requirements • Target multiple platforms from a single codebase • Apps must feel like they belong on the platform http://www.on3solutions.com | Elements to grow from within 8
  • 17. Our Requirements • Target multiple platforms from a single codebase • Apps must feel like they belong on the platform • Apps need to perform like native http://www.on3solutions.com | Elements to grow from within 8
  • 18. Our Requirements • Target multiple platforms from a single codebase • Apps must feel like they belong on the platform • Apps need to perform like native • Bonus: Open source and extensible http://www.on3solutions.com | Elements to grow from within 8
  • 19. Our Requirements • Target multiple platforms from a single codebase • Apps must feel like they belong on the platform • Apps need to perform like native • Bonus: Open source and extensible • Bonus: Use skills we already have http://www.on3solutions.com | Elements to grow from within 8
  • 20. A Solution • Titanium Mobile • JavaScript library for building native applications • Open Source (Apache 2.0 License) • Mobile Platforms • iPhone, Android, Blackberry, webOS (soon) • Desktop Platforms • Win32, Mac, Linux • Website: http://appcelerator.com http://www.on3solutions.com | Elements to grow from within 9
  • 21. Why Titanium Mobile? • Build Native Apps (not WebKit apps) • Responsive • Leverage Device Capabilities • Use Web Technologies • Common Skill Set • Very Fast Development • No Objective-C • Best of both worlds • One set of technologies, many platforms http://www.on3solutions.com | Elements to grow from within 10
  • 22. Titanium Mobile – Architecture UI API contains mappings to native UI components Application Source Files • Navbar, Tabbar, Toolbar, Menus (HTML, CSS, and JavaScript) • Dialogs, Alerts, Buttons Phone API contains mappings to native phone capabilities • Geo, Accelerometer, Maps, Sound • Database, File System, Network Your Application Your Application UI API Phone API UI API Phone API JavaScript - Objective-C Bridge JavaScript - Java Bridge iPhone Objective-C API Android Java API Native iPhone App Native Android App http://www.on3solutions.com | Elements to grow from within
  • 23. Titanium Features Native UI Rich Media APIs Real native tables, tabs, sliders, Local and streaming audio and and views video, media recording Location APIs Open Source and Extensible Native Maps, Compass, and Extend Titanium with custom Geolocation modules in native code Local and Remote Data Integrated Analytics Local SQL Database, Lightweight Baked-in analytics APIs to measure Key/Value Store, XHR results and behavior Social APIs Development Tools Integrated Facebook Connect Develop and distribute your app for and YQL multiple platforms from a single tool http://www.on3solutions.com | Elements to grow from within 12
  • 24. What its not • Not a native wrapper around a web view (PhoneGap being an example of this approach) • However, you do have a web view component for HTML/CSS UI if that is your preference • Your JavaScript code is invoking native APIs for UI and other native functions • Think MacRuby/Hot Cocoa on the desktop or some AAA mobile games which ship with a Lua interpreter http://www.on3solutions.com | Elements to grow from within 13
  • 28. Titanium Developer • Manage and run Titanium applications • Package applications for distribution • Run on a device for testing • Manage Appcelerator account http://www.on3solutions.com | Elements to grow from within 17
  • 29. Getting started • Project created/managed via Titanium Developer • Titanium Developer • deploys code to simulators • helps with testing and packaging for devices • Requires sign-up for Appcelerator Network (support, e-mail list, other services) http://www.on3solutions.com | Elements to grow from within 18
  • 30. Getting started • Project created/managed via Titanium Developer • Titanium Developer • deploys code to simulators • helps with testing and packaging for devices • Requires sign-up for Appcelerator Network (support, e-mail list, other services) Its FREE (as in beer!) http://www.on3solutions.com | Elements to grow from within 18
  • 31. Hello World • Prerequisites • iPhone and/or Android SDK • Titanium Developer • Your First Project •Creating a mobile project •Mobile project structure •Editing code, adding UI widgets to the app •Deploy to simulator http://www.on3solutions.com | Elements to grow from within 19
  • 32. KitchenSink • Example Code • Living Reference Document • Demonstrates API coverage http://www.on3solutions.com | Elements to grow from within 20
  • 33. Titanium Fundamentals • Titanium application is a JavaScript program that is interpreted at runtime on the device • app.js defines the root execution context of the app • Note: not running in a browser • It uses the WebKit KJS JavaScript engine (iOS) or Rhino (Android/BB) http://www.on3solutions.com | Elements to grow from within 21
  • 34. How it works • Titanium takes the Javascript code •Analyzes and preprocesses it •Pre-compiles it into a set of symbols •Symbols are resolved based on your applications uses of the Titanium APIs • From this symbol hierarchy •Build a symbol dependency matrix that maps to the underlying Titanium library symbols •Understand which APIs specifically your app needs • Compiled almost one to one into the representative symbols in native-land http://www.on3solutions.com | Elements to grow from within 22
  • 35. Scripts and Stylesheets • Organized into logical namespaces • “Titanium” (or just “Ti” for short) is the root namespace for all Titanium functionality • A few other odds and ends in the global space – setTimeout/setInterval – alert – JSON http://www.on3solutions.com | Elements to grow from within 23
  • 36. Design the UI • A single window or stack of windows • Tab Group containing many windows • Windows contain views http://www.on3solutions.com | Elements to grow from within 24
  • 37. Windows and Context • Windows are the top level container for Titanium applications • Applications usually consist of one window or several windows in a tab group • Windows usually create new execution contexts •Execution context == A unique JavaScript symbol space • Such windows are “Heavyweight” windows • Can also create “Lightweight” windows (for apps that run in a single context) http://www.on3solutions.com | Elements to grow from within 25
  • 38. Demo Contexts • New Project - Two Tabs with “Lightweight” windows • Switch to contain urls and contexts • Symbols not defined in other contexts http://www.on3solutions.com | Elements to grow from within 26
  • 39. View Hierarchy • Views are the building blocks of Titanium UIs – Specialized views: table views, image views, map views, etc. • Views can contain child views, which are positioned relative to the parent • Layout Options: Absolute, vertical, or horizontal (currently iPhone only) • Vertical layouts require height to be set http://www.on3solutions.com | Elements to grow from within 27
  • 40. Custom Events • Use for cross-context messaging • Events are received across all ACTIVE contexts • Windows not yet open do not receive events • Use also as an inversion of control mechanism – Publish message when the database has been updated – Publish message when contacting a server – Using pub/sub messaging is very useful in a component-oriented framework like Titanium http://www.on3solutions.com | Elements to grow from within 28
  • 41. Demo: Events • Now lets use custom events in our new app • Events can have a data payload • Remember that events are only received in active contexts http://www.on3solutions.com | Elements to grow from within 29
  • 42. Cross Platform • Not all UI is available across platforms • Titanium != Write Once, Run Everywhere • It tries to enable native apps that look and feel like they were created in Objective-C or Java • Also note that even cross-platform UI components (like table views) will render differently cross platform • Cross Platform testing is critical during development cycle http://www.on3solutions.com | Elements to grow from within 30
  • 43. Cross Platform Tips • iPhone/Android subdirectories • Ti.Platform.osname • Display height/width • OS version • Check Out Kitchen Sink Platform example http://www.on3solutions.com | Elements to grow from within 31
  • 44. Build an Example • App Features: – Multiple Window/Tabbed UI – Properties API – Camera and Local Photo Gallery – Upload to remote web service (TwitPic) • Want to develop and deploy to a device in the space of a few minutes http://www.on3solutions.com | Elements to grow from within 32
  • 45. iPhone SDK Users • Will need to download build to address iOS 4 issues that is not in basic 1.3.0 release • Nightly Builds: – http://builds.appcelerator.com.s3.amazonaws.com/index.html • Let’s go through install of “latest and greatest” build... http://www.on3solutions.com | Elements to grow from within 33
  • 46. OhSnap! • New Project via Titanium Developer • Grab new icons from Glyphish • Configure tab icons, new windows/ execution contexts http://www.on3solutions.com | Elements to grow from within 34
  • 47. 1. Gather UI • Create necessary buttons, image placeholders, text labels • Arrange using vertical layout • Check out styling options http://www.on3solutions.com | Elements to grow from within 35
  • 48. 2. Login Screen • Pre-populate text fields with Properties • Persist un/pw combo • Add event listener to save button http://www.on3solutions.com | Elements to grow from within 36
  • 49. 3. Media • Open Photo Gallery • Show Camera • Dynamically update ImageView source file http://www.on3solutions.com | Elements to grow from within 37
  • 50. 4. Upload Image • Create HTTPClient object • Open a POST request • Upload image media and Twitter update http://www.on3solutions.com | Elements to grow from within 38
  • 51. Deploy • Demo: Deploy via Titanium Developer • On your own, provision your system for development on device • Android == super easy • iPhone... not so much • Video Tutorial: – http://vimeo.com/10278960 • All Appcelerator Videos: – http://vimeo.com/appcelerator http://www.on3solutions.com | Elements to grow from within 39
  • 52. Recap OhSnap! • < 200 Lines of code • Persistent App Preferences • Fully native UI (ugly, but see Snapost for the pretty...) • Integrated camera/photo gallery • XML HTTP Request upload to remote server • 100% Cross-Platform http://www.on3solutions.com | Elements to grow from within 40
  • 53. Next Steps http://www.on3solutions.com | Elements to grow from within 41
  • 54. Next Steps • Deploy to device http://www.on3solutions.com | Elements to grow from within 41
  • 55. Next Steps • Deploy to device • Submit to market http://www.on3solutions.com | Elements to grow from within 41
  • 56. Next Steps • Deploy to device • Submit to market • Make (or save) your company millions! http://www.on3solutions.com | Elements to grow from within 41
  • 57. Next Steps • Deploy to device • Submit to market • Make (or save) your company millions! • Buy me a Bookers --> http://www.on3solutions.com | Elements to grow from within 41
  • 58. Thank you • On3 Grow Your Own • Consulting, Mentoring, Training Flex Team • http://www.on3solutions.com •Twitter: on3solutions Tired of IT outsourcing? Cultivate expertise from within with the help • Rob Rusher of On3. We mentor development teams through the process of implementing, developing and mastering next-generation • http://www.robrusher.com technologies. We also o er traditional needs assessment and e ective instruction. Call On3, and prepare to watch your capabilities grow. •Twitter: robrusher On3 Solutions sales@on3solutions.com 3 www.on3solutions.com 877.885.7044 303.885.7044 On http://www.on3solutions.com | Elements to grow from within 42
  • 59. Resources • Get Titanium Mobile • http://www.appcelerator.com • Titanium Reference • http://www.codestrong.com • Kevin Whinnery • http://kevinwhinnery.com • Code for this presentation • http://github.com/kwhinnery http://www.on3solutions.com | Elements to grow from within 43

Editor's Notes