52
James Pearce @jamespearce ACCESSING NATIVE APIS FROM SENCHA TOUCH Wednesday, November 2, 11

Accessing Native APIs from Touch

  • Upload
    sencha

  • View
    9.746

  • Download
    0

Embed Size (px)

DESCRIPTION

Learn how to use hybrid technologies like PhoneGap and NimbleKit to hook into native device capabilities, and then distribute your mobile applications into app stores and marketplaces.Aditya Bansod is Sencha’s senior director of product management and is responsible for the product planning and strategy for Sencha’s product lines. Prior to Sencha, Aditya held various senior product management roles at Adobe and Microsoft, focusing on developers and media in the mobile and consumer electronics space.James Pearce heads developer relations at Sencha. He is a technologist, writer, developer and practitioner, who has been working with the mobile web for over a decade. Previously he was the CTO at dotMobi and has a background in mobile startups, telecoms infrastructure and management consultancy. James is the creator of tinySrc, the WordPress Mobile Pack, WhitherApps, modernizr-server and confess.js, and has written books on mobile web development for both Wiley and Wrox.

Citation preview

Page 1: Accessing Native APIs from Touch

James Pearce@jamespearce

ACCESSING NATIVE APIS FROMSENCHA TOUCH

Wednesday, November 2, 11

Page 2: Accessing Native APIs from Touch

Web apps arethe future

Wednesday, November 2, 11

Page 3: Accessing Native APIs from Touch

Native apps arethe present

Wednesday, November 2, 11

Page 4: Accessing Native APIs from Touch

Native Web

Cross-platform ✘ ✔

Linkable ✘ ✔

Discoverable ✔ ✘

Device APIs ✔ ✘

Wednesday, November 2, 11

Page 5: Accessing Native APIs from Touch

Native Web Hybrid

Cross-platform ✘ ✔ ✔

Linkable ✘ ✔ ✔

Discoverable ✔ ✘ ✔

Device APIs ✔ ✘ ✔

Wednesday, November 2, 11

Page 6: Accessing Native APIs from Touch

What is a hybrid app?

Wednesday, November 2, 11

Page 7: Accessing Native APIs from Touch

Nativeness

Site

Nativeapps

Websites

Webapps

App

Wednesday, November 2, 11

Page 8: Accessing Native APIs from Touch

Nativeness

Site

Nativeapps

Websites

Webapps

Hybridapps

App

Wednesday, November 2, 11

Page 9: Accessing Native APIs from Touch

Workers & Parallel

Processing

File SystemsDatabases

App Caches

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

HTTP

AJAX

Events

Sockets

SSL

Wednesday, November 2, 11

Page 10: Accessing Native APIs from Touch

WebView

Workers & Parallel

Processing

File SystemsDatabases

App Caches

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

HTTP

AJAX

Events

Sockets

SSL

Wednesday, November 2, 11

Page 11: Accessing Native APIs from Touch

Workers & Parallel

Processing

File SystemsDatabases

App Caches

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

Native Wrapper

WebView

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics HTTP

AJAX

Events

Sockets

SSL

Wednesday, November 2, 11

Page 12: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 13: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 14: Accessing Native APIs from Touch

Sencha TouchPackager

Edmund Leung, Product Manager

Wednesday, November 2, 11

Page 15: Accessing Native APIs from Touch

Workers & Parallel

Processing

File SystemsDatabases

App Caches

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

Native Wrapper

WebView

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics HTTP

AJAX

Events

Sockets

SSL

Wednesday, November 2, 11

Page 16: Accessing Native APIs from Touch

Native Wrapper

WebView

Workers & Parallel

Processing

File SystemsDatabases

App Caches

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

HTTP

AJAX

Events

Sockets

SSL

Wednesday, November 2, 11

Page 17: Accessing Native APIs from Touch

Device Access

Wednesday, November 2, 11

Page 18: Accessing Native APIs from Touch

Media Capture (HTML)Battery statusContactsMessaging (SMS, MMS...)Network Information API

Media Capture (API) Application RegistrationCalendarFeature PermissionsSensor APIVibration APIMenu APIPermissions for APIsAudio Volume

BeepGallerySystems info and eventsTasks

Wednesday, November 2, 11

Page 19: Accessing Native APIs from Touch

AccelerometerOrientationCameraDeviceStatusFilesystemMessagingGeolocationPIM ContactsCalendarTasksDeviceInteraction

APDU (SmartCard)BluetoothCryptoDLNAServer PushSensor Telephony

Wednesday, November 2, 11

Page 20: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 21: Accessing Native APIs from Touch

TelephonyMessagingContactsClockCameraFilesystemCalculatorDevice StatusSettingsAccelerometerMouse LockMaps

Wednesday, November 2, 11

Page 22: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 23: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 24: Accessing Native APIs from Touch

Developer choice is limited by options

Wednesday, November 2, 11

Page 25: Accessing Native APIs from Touch

Native Wrapper

Workers & Parallel

Processing

File SystemsDatabases

App Caches

JavaScript

Semantic HTML

CSS Styling & Layout

WebFont Video Audio Graphics

Cross-AppMessaging

Camera

Location

Contacts

SMS

Orientation

Gyro

HTTP

AJAX

Events

Sockets

SSL

WebView

Wednesday, November 2, 11

Page 26: Accessing Native APIs from Touch

PhoneGap

Wednesday, November 2, 11

Page 27: Accessing Native APIs from Touch

Apache

Wednesday, November 2, 11

Page 28: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 29: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 30: Accessing Native APIs from Touch

AccelerometerTap into the device’s motion sensor.

CameraCapture a photo using the device's camera.

CaptureCapture media files using device's media capture applications.

CompassObtain the direction the device is pointing.

ConnectionQuickly check the network state, and cellular network information.

ContactsWork with the devices contact database.

DeviceGather device specific information.

EventsHook into native events through JavaScript.

FileHook into native file system through JavaScript.

GeolocationMake your application location aware.

MediaRecord and play back audio files.

NotificationVisual, audible, and tactile device notifications.

StorageHook into the device’s native storage options.

Wednesday, November 2, 11

Page 31: Accessing Native APIs from Touch

Project Setup

Wednesday, November 2, 11

Page 32: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 33: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 34: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 35: Accessing Native APIs from Touch

PhoneGap.plist

Wednesday, November 2, 11

Page 36: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 37: Accessing Native APIs from Touch

Wednesday, November 2, 11

Page 38: Accessing Native APIs from Touch

AndroidManifest.xml

Wednesday, November 2, 11

Page 39: Accessing Native APIs from Touch

Project Setup

Wednesday, November 2, 11

Page 40: Accessing Native APIs from Touch

AccelerometerTap into the device’s motion sensor.

CameraCapture a photo using the device's camera.

CaptureCapture media files using device's media capture applications.

CompassObtain the direction the device is pointing.

ConnectionQuickly check the network state, and cellular network information.

ContactsWork with the devices contact database.

DeviceGather device specific information.

EventsHook into native events through JavaScript.

FileHook into native file system through JavaScript.

GeolocationMake your application location aware.

MediaRecord and play back audio files.

NotificationVisual, audible, and tactile device notifications.

StorageHook into the device’s native storage options.

Wednesday, November 2, 11

Page 41: Accessing Native APIs from Touch

Camera

navigator.camera.getPicture(

function(imageData) { },

function (message) { },

{} //options

);

Wednesday, November 2, 11

Page 42: Accessing Native APIs from Touch

navigator.contacts.create( {}).save();

navigator.contacts.find( contactFields, function(){}, function(){}, {});

Contacts

Wednesday, November 2, 11

Page 43: Accessing Native APIs from Touch

Demo

Wednesday, November 2, 11

Page 44: Accessing Native APIs from Touch

Plugins

AdPlugin/ApplicationPreferences/

AudioEncode/AudioRecord/

Badge/BarcodeScanner/BundleFileReader/

ChildBrowser/ClipboardPlugin/

DatePicker/EmailComposer/

FileUploader/GapSocket/

Globalization/HockeyApp/

InAppPurchaseManager/Keychain/

LocalNotification/Localizable/MapKitPlug/

NativeControls/NotificationEx/PayPalPlugin/

PowerManagement/PrintPlugin/

Prompt/SMSComposer/

ScreenShot/ShareKitPlugin/

SoundPlug/SplashScreen/

TestFlight/Torch/

VolumeSlider/

Wednesday, November 2, 11

Page 45: Accessing Native APIs from Touch

Caveats

Wednesday, November 2, 11

Page 46: Accessing Native APIs from Touch

Obfuscation != security

+ =

Wednesday, November 2, 11

Page 47: Accessing Native APIs from Touch

Quirks

...Wednesday, November 2, 11

Page 48: Accessing Native APIs from Touch

Androidphonegap.js

iOSphonegap.js ...

Wednesday, November 2, 11

Page 49: Accessing Native APIs from Touch

Avoid start racedocument.addEventListener( "deviceready", app.mainLaunch, false);

new Ext.Application({ launch: function() { this.launched = true; this.mainLaunch(); }, mainLaunch: function() { if (!device || !this.launched) {return;} ... }});

Wednesday, November 2, 11

Page 50: Accessing Native APIs from Touch

Wouldn’t it begreat if...

Wednesday, November 2, 11

Page 51: Accessing Native APIs from Touch

Further...

http://sencha.com/x/cy

http://sencha.com/x/de

BlackBerry WebWorks APIs3:50pm - 4:30pm

Wednesday, November 2, 11

Page 52: Accessing Native APIs from Touch

THANKS

James Pearce@jamespearce

Wednesday, November 2, 11