PhoneGap

Facebook Hack
Steve Gill
    PhoneGap Champ
facebook.com/stevengill97
       @SteveSGill
   steveng@adobe.com
What is PhoneGap?
PhoneGap
PhoneGap
      &
Apache Cordova
PhoneGap Pattern


1. Embed a chromeless browser in a native app
2. Create a “bridge” between the browser and the
   native code
3. Write a web app
4. Package the web app with the native code and deploy
   to devices!
Write once debug everywhere
Supported Platforms
•   iOS (iPad, iPod Touch, iPhone)
•   Android (Everything)
•   BlackBerry (Smartphones, PlayBook)
•   WebOS
•   Windows Phone
•   Symbian
•   Bada
Lay of the Land
iOS .............................. Objective C
Android ...................... Java ‘Harmony’ / C++
BlackBerry ................. Java J2ME / C++ (maybe?)
webOS ........................ HTML, CSS and JS
Windows Phone 7 ... .NET
Bada ............................. C++
How do you write
 PhoneGap apps?
Basics: HTML


<button>I’m native codes!</button>
Setup the Viewport


<meta name="viewport" content="width=dev
ice-width, initial-scale=1.0, maximum-
scale=1.0, user-scalable=no;" />
Basics: CSS3

• Media queries come in handy for tablets
• Many folk using precompilers these days
• Opacity, rounded corners, gradients and
  fucking drop shadows fuck ya!
CSS3 Animations


-webkit-transform:
  translate3d(x,y,z) scale3D(1,1,1.0)
Media Query
Media Query
<link rel="stylesheet" media="all and (max-device-
width: 480px)" href="iphone.css">
Media Query
<link rel="stylesheet" media="all and (max-device-
width: 480px)" href="iphone.css">
<link rel="stylesheet" media="all and (min-device-
width: 481px) and (max-device-width: 1024px) and
(orientation:portrait)" href="ipad-portrait.css">
Media Query
<link rel="stylesheet" media="all and (max-device-
width: 480px)" href="iphone.css">
<link rel="stylesheet" media="all and (min-device-
width: 481px) and (max-device-width: 1024px) and
(orientation:portrait)" href="ipad-portrait.css">
<link rel="stylesheet" media="all and (min-device-
width: 481px) and (max-device-width: 1024px) and
(orientation:landscape)" href="ipad-
landscape.css">
Media Query
<link rel="stylesheet" media="all and (max-device-
width: 480px)" href="iphone.css">
<link rel="stylesheet" media="all and (min-device-
width: 481px) and (max-device-width: 1024px) and
(orientation:portrait)" href="ipad-portrait.css">
<link rel="stylesheet" media="all and (min-device-
width: 481px) and (max-device-width: 1024px) and
(orientation:landscape)" href="ipad-
landscape.css">
Basics: JavaScript

• Language of the web.
• Scheme with a C syntax.
• Some quirks: http://wtfjs.com
Startup

document.addEventListener(
  ‘deviceready’,
  function() {
     alert(‘WINNING!’);
  },
  false);
Performance

• Use those CSS transforms
• Don’t set style properties inside a loop
• Don’t do what you do on the web
Clear as Mud
Clear as Mud
• WRITE IN HTML, JAVASCRIPT AND CSS
Clear as Mud
• WRITE IN HTML, JAVASCRIPT AND CSS
• PRODUCE A NATIVE APP PACKAGED
  PACKAGED ON A PER PLATFORM BASIS
Clear as Mud
• WRITE IN HTML, JAVASCRIPT AND CSS
• PRODUCE A NATIVE APP PACKAGED
  PACKAGED ON A PER PLATFORM BASIS
• NO CROSS COMPILING MAGIC
Clear as Mud
• WRITE IN HTML, JAVASCRIPT AND CSS
• PRODUCE A NATIVE APP PACKAGED
  PACKAGED ON A PER PLATFORM BASIS
• NO CROSS COMPILING MAGIC
• NO FAIRY DUST / SPARKLES
Clear as Mud
• WRITE IN HTML, JAVASCRIPT AND CSS
• PRODUCE A NATIVE APP PACKAGED
  PACKAGED ON A PER PLATFORM BASIS
• NO CROSS COMPILING MAGIC
• NO FAIRY DUST / SPARKLES
• NO UNICORNS GET HURT
Partners / Contributors
•   Adobe
•   IBM
•   Sony Ericsson
•   Symbian
•   HP/Palm
•   RIM
•   Microsoft
Power Users

• Alcatel Lucent
• Sabre
• Deutsche Telecom
• Ars Technica
• WikiMedia
PhoneGap APIs

• Sensors
• Data
• Events

        http://docs.phonegap.com
Sensors

• GPS
• Accelerometer
• Compass
• Network
• Camera
Data

• Contacts
• Media
• File system
• Notifications
Events

• onload (duh)
• ondeviceready (this is special)
• onnativeready
• onresume
• onpause
Tooling
• Use any IDE
• Use the platform emulators (at your peril)
• Use Ripple emulator
• Use Web Inspector Remote (Weinre)
• Srsly use Weinre
• Console.log and alert =(
Libraries

• DOM
• Testing
• Style / GUI
• Persistence
Plugins
Facebook PhoneGap
          Plugin
Take your mobile Facebook app and make it native
        Take advantage of PhoneGap APIs
       Distribute in app stores & go offline
How the Fb Plugin
           Works
Adds hooks into Facebook JS SDK to call the plugin
   Maps some FB JS calls to native FB iOS SDK
Demo
More Fb Plugin Info
                      Source Code:
github.com/davejohnson/phonegap-plugin-facebook-connect
                    iOS Install video:
                 youtube.com/phonegap
              Android Video Coming Soon!
project resources
                    phonegap.com
                    docs.phonegap.com
                    wiki.phonegap.com
                    git.apache.org
                    issues.apache.org/jira/browse/CB
                    groups.google.com/group/phonegap
                    twitter.com/phonegap
                    facebook.com/phonegap
                    #phonegap on freenode
                    youtube.com/phonegap
    thank you       github.com/davejohnson/phonegap-
                    plugin-facebook-connect

Phonegap facebook- plugin

Editor's Notes