Slide 1

Slide 1 text

State of the gap Remy Sharp ☛ @rem

Slide 2

Slide 2 text

PhoneGap: The polyfill

Slide 3

Slide 3 text

PhoneGap is a polyfill, Brian LeRoux, SPACELORD!1!! Adobe, 2012. PhoneGap is a polyfill, and the ultimate purpose of PhoneGap PhoneGap is a polyfill, and the ultimate purpose of PhoneGap is to cease to exist. “

Slide 4

Slide 4 text

Meanwhile, 7 years later…

Slide 5

Slide 5 text

PhoneGap core

Slide 6

Slide 6 text

Dialogs alert('OG dialogs ')

Slide 7

Slide 7 text

Camera

Slide 8

Slide 8 text

window.addEventListener('deviceorientation', handler) Accelerometer & Compass window.addEventListener('devicemotion', handler)

Slide 9

Slide 9 text

var reader = new FileReader(); reader.onload = e => img.src = e.target.result; reader.readAsDataURL(this.files[0]); // this = input[type=file] Files

Slide 10

Slide 10 text

function upload(blobOrFile) { var xhr = new XMLHttpRequest(); xhr.open('POST', '/server', true); xhr.onload = e => { /* show done…or something */ }; var progressBar = document.querySelector('progress'); xhr.upload.onprogress = e => { // track upload progress if (e.lengthComputable) { progressBar.value = (e.loaded / e.total) * 100; } }; xhr.send(blobOrFile); } upload(new Blob(['hello world'], {type: 'text/plain'})); File Transfer

Slide 11

Slide 11 text

// now requires secure origin: HTTPS navigator.geolocation.getCurrentPosition(ok, fail); Geolocation

Slide 12

Slide 12 text

function done(stream) { var url = window.URL.createObjectURL(stream); video.src = url; // starts to play video } navigator.getUserMedia({ video: true }, done, console.error); Media Capture

Slide 13

Slide 13 text

navigator.getBattery()
 .then(b => b.level) .then(console.log); Battery

Slide 14

Slide 14 text

navigator.connection.type; // wifi/cellular/none navigator.connection.ontypechange(handler) Network information

Slide 15

Slide 15 text

navigator.vibrate(1000); Vibration

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

PhoneGap vs. the web The ecosystem vs.

Slide 19

Slide 19 text

Cross browser support Or…“the reason I left programming for the web”

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

plugins > browsers

Slide 22

Slide 22 text

App Stores

Slide 23

Slide 23 text

App Stores: 20% CPA

Slide 24

Slide 24 text

1. Visit app store 800 users 2. Find app 640 users 3. Click install 512 users 4. Accept permissions 410 users 5. Download and wait 328 users 6. Use! 262 users left. 1000 users are interested in this app

Slide 25

Slide 25 text

Full flow: 262 Direct install: 410 1000 users are interested in this app http://bit.ly/20pcent-dropoff

Slide 26

Slide 26 text

What if…

Slide 27

Slide 27 text

Progressive Web Apps

Slide 28

Slide 28 text

3X more time on site 40% high re-engagement 70% greater conversion from homescreen 3X lower data usage https://bit.ly/flipkart-study

Slide 29

Slide 29 text

Security: TLS/HTTPS, permissions Performance: fast, responsive (in all senses) Availability: control of the network, homescreen, push notifications

Slide 30

Slide 30 text

Requires manifest
 and service worker.

Slide 31

Slide 31 text

If I add this app to my home screen, it will work when I open it.

Slide 32

Slide 32 text

If I add this app to my home screen, it must work when I open it.

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

“Push notifications allowed us to bring one of the most compelling capabilities from our native app to our mobile site. We see a direct 20% click through rate from push notifications…” http://bit.ly/pwa-study-btr – Beyond the Rack

Slide 35

Slide 35 text

1. HTTPS 2. Service Worker 3. Manifest 4. Push notifications

Slide 36

Slide 36 text

Service workers Event driven Uses promises and fetch API Register your service worker Then: install, fetch, activate, push

Slide 37

Slide 37 text

// progressively enhance if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js'); } http://bit.ly/sw-copy-paste

Slide 38

Slide 38 text

const name = 'v1:static'; self.addEventListener('install', e => { // once the SW is installed, go ahead and fetch the // resources to make this work offline e.waitUntil( caches.open(name).then(cache => { return cache.addAll([ '/', // and other urls ]).then(() => self.skipWaiting()); }) ); }); http://bit.ly/sw-copy-paste

Slide 39

Slide 39 text

// when the browser fetches a url, either response // with the cached object or go ahead and fetch // the actual url self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request).then( res => res || fetch(event.request) ) ); }); http://bit.ly/sw-copy-paste

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Slide 43

Slide 43 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Preferred name property, appears on homescreen and on dynamic splash screen

Slide 44

Slide 44 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Array of icons available, at least include 192x192

Slide 45

Slide 45 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Optionally serve specific page to homescreen apps (and track)

Slide 46

Slide 46 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } standalone, fullscreen, browser - how your appears on the device

Slide 47

Slide 47 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Games might choose to use landscape

Slide 48

Slide 48 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Colour used on dynamic splash page

Slide 49

Slide 49 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" } Colour used on Chrome tab

Slide 50

Slide 50 text

{ "short_name": "My sweet app", "name": "This be the bees knees sweet app", "icons": [ { "src": "icon-4x.png", "sizes": "192x192", "type": "image/png" } ], "start_url": "/?utm_source=web_app_manifest", "display": "standalone", "orientation": "portrait", "background_color": "#ff0000", "theme_color": "#00ff00" }

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Polymer: starter kit & elements WebRTC: PeerJS WebSockets: BinaryJs NodeJS Material Design

Slide 54

Slide 54 text

Polymer: starter kit & elements WebRTC: PeerJS WebSockets: BinaryJs NodeJS Material Design UX:

Slide 55

Slide 55 text

“We agree that there are no silver bullets, and the web isn’t the best tool for every job…

Slide 56

Slide 56 text

“However, the web is not getting worse…

Slide 57

Slide 57 text

“If the web doesn’t do something today it’s not because it can’t, or won’t…

Slide 58

Slide 58 text

“but rather it is because we haven't gotten around to implementing that capability yet.

Slide 59

Slide 59 text

“but rather it is because we haven't gotten around to implementing that capability yet.

Slide 60

Slide 60 text

Thanks 
 (and thanks Brian)