progressive web apps - .net conf co 2017

110
PROGRESSIVE WEB APPS Nicolás Bello Camilletti @nbellocam SOUTHWORKS

Upload: nicolas-bello-camilletti

Post on 23-Jan-2018

205 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APPSNicolás Bello Camilletti

@nbellocam

SOUTHWORKS

Page 2: Progressive Web Apps - .NET Conf CO 2017
Page 3: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APP

Es un conjunto de

conceptos/herramientas/etc.

Page 4: Progressive Web Apps - .NET Conf CO 2017

WEB COMO NATIVO

No es un concepto nuevo

Page 5: Progressive Web Apps - .NET Conf CO 2017

native web

Page 6: Progressive Web Apps - .NET Conf CO 2017

native web

Page 7: Progressive Web Apps - .NET Conf CO 2017
Page 8: Progressive Web Apps - .NET Conf CO 2017

WEB APPS EN WINDOWS

Pinned SitesWindows 7

Page 9: Progressive Web Apps - .NET Conf CO 2017

WEB APPS EN WINDOWS

Pinned SitesWindows 7

Packaged WAWindows 8

Page 10: Progressive Web Apps - .NET Conf CO 2017

WEB APPS EN WINDOWS

Pinned SitesWindows 7

Packaged WAWindows 8

Hosted Web AppsWindows 10

Page 11: Progressive Web Apps - .NET Conf CO 2017

WEB APPS EN WINDOWS

Pinned SitesWindows 7

Packaged WAWindows 8

PWAWindows 10

Hosted Web AppsWindows 10

Page 12: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APPa.k.a. “PWA”

Page 13: Progressive Web Apps - .NET Conf CO 2017

PWA & ANDROID

Page 14: Progressive Web Apps - .NET Conf CO 2017

Lyftride.lyft.com

Page 15: Progressive Web Apps - .NET Conf CO 2017

Lyftride.lyft.com

Page 16: Progressive Web Apps - .NET Conf CO 2017
Page 17: Progressive Web Apps - .NET Conf CO 2017
Page 18: Progressive Web Apps - .NET Conf CO 2017
Page 19: Progressive Web Apps - .NET Conf CO 2017
Page 20: Progressive Web Apps - .NET Conf CO 2017

BENEFICIOS DE WEB APPS

Page 21: Progressive Web Apps - .NET Conf CO 2017

WEB APPS ANDAN

EN CUALQUIER LUGAR!

Page 22: Progressive Web Apps - .NET Conf CO 2017
Page 23: Progressive Web Apps - .NET Conf CO 2017
Page 24: Progressive Web Apps - .NET Conf CO 2017

ONE CODEBASE

TO RULE THEM ALL…

Page 25: Progressive Web Apps - .NET Conf CO 2017

PWAS = MENOR COSTO (& TIEMPO)

App core

iPhone iPad Publicar en App Store

Android Phone

Android Tablet Publicar en Play Store

Windows Publicar en Windows Store

MacOS Publicar en Mac App Store

Web Host

NativaEs requerido publicar en los App store

Page 26: Progressive Web Apps - .NET Conf CO 2017

PWAS = MENOR COSTO (& TIEMPO)PWAPublicar en los App store es opcional (o por única vez)

Host

Gratis

App core

iPhone iPad

Android Phone

Android Tablet

Windows

MacOS

Web

Other PWA-capable

Page 27: Progressive Web Apps - .NET Conf CO 2017

PRINCIPIOS DE PWA

Page 28: Progressive Web Apps - .NET Conf CO 2017

PWAS SON SIMPLEMENTE WEB APPS…

Page 29: Progressive Web Apps - .NET Conf CO 2017

PWAS SON SIMPLEMENTE WEB APPS…

¡QUE PROVEEN DE UNA EXCELENTE

EXPERIENCIA DE USUARIO!

Page 30: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Page 31: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Progressive

Page 32: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APP

Page 33: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE ENHANCEMENT

Page 34: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

Mono

Page 35: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

Stereo

Page 36: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

Surround Sound

Page 37: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

5.1 ChannelSurround Sound

Page 38: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

7.1 ChannelSurround Sound

Page 39: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

16.2 Channel Surround Sound

Page 40: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

A veces, mono esla única opción

Page 41: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

Objectivo &tareas principales

Page 42: Progressive Web Apps - .NET Conf CO 2017

¿QUÉ ES PROGRESSIVE ENHANCEMENT?

Capacidades

Exp

erie

ncia

Page 43: Progressive Web Apps - .NET Conf CO 2017

PE SE ASEGURA DE QUE LOS

USUARIOS PUEDAN USAR TU

PRODUCTO SIN IMPORTAR EL

CONTEXTO.

Page 44: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE ENHANCEMENT WEB

Page 45: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE ENHANCEMENT WEB

type="email"

Deltasdeexperiencia1. ¿Soporta input para email?2. ¿Algoritmo devalidación

implementado?3. ¿Teclado virtual?

Page 46: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE ENHANCEMENT WEB

required

Deltasdeexperiencia1. ¿Soporta validación HTML?

Page 47: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE ENHANCEMENT WEB

aria-required="true"

Deltasdeexperiencia1. ¿El navegador expone la propiedad aria-required ?2. ¿Tiene implementado la asistencia para aria-required?

Page 48: Progressive Web Apps - .NET Conf CO 2017

required validation

email validation

dedicated keyboard

Capabilities

Expe

rienc

e

text input required notification

PROGRESSIVE ENHANCEMENT WEB

Page 49: Progressive Web Apps - .NET Conf CO 2017

PE SE ASEGURA DE QUE LOS

USUARIOS PUEDAN USAR TU

PRODUCTO SIN IMPORTAR EL

CONTEXTO.

Page 50: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Progressive Responsive

Page 51: Progressive Web Apps - .NET Conf CO 2017

PWA ES

NetworkIndependent

Progressive Responsive

Page 52: Progressive Web Apps - .NET Conf CO 2017
Page 53: Progressive Web Apps - .NET Conf CO 2017
Page 54: Progressive Web Apps - .NET Conf CO 2017
Page 55: Progressive Web Apps - .NET Conf CO 2017

PWA ES

NetworkIndependent

Progressive Responsive App-Like

Page 56: Progressive Web Apps - .NET Conf CO 2017

PWA O APP NATIVA?

Page 57: Progressive Web Apps - .NET Conf CO 2017

PWA ES

NetworkIndependent

Progressive Responsive App-Like Fresh

Page 58: Progressive Web Apps - .NET Conf CO 2017

PWA ES

NetworkIndependent

Segura

Progressive Responsive App-Like Fresh

Page 59: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Discoverable

NetworkIndependent

Segura

Progressive Responsive App-Like Fresh

Page 60: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Discoverable

NetworkIndependent

Segura Re-engageable

Progressive Responsive App-Like Fresh

Page 61: Progressive Web Apps - .NET Conf CO 2017
Page 62: Progressive Web Apps - .NET Conf CO 2017
Page 63: Progressive Web Apps - .NET Conf CO 2017
Page 64: Progressive Web Apps - .NET Conf CO 2017
Page 65: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Discoverable Instalable

NetworkIndependent

Segura Re-engageable

Progressive Responsive App-Like Fresh

Page 66: Progressive Web Apps - .NET Conf CO 2017

LA APP VA A SEGUIR ANDANDO EN EL

BROWSER. SÓLO PODRÍA HACER MÁS

COSAS CUANDO SE “INSTALE”.

Page 67: Progressive Web Apps - .NET Conf CO 2017

WHATWEBCANDO.TODAY

Page 68: Progressive Web Apps - .NET Conf CO 2017

PWA ES

Discoverable Instalable Linkeable

NetworkIndependent

Segura Re-engageable

Progressive Responsive App-Like Fresh

Page 69: Progressive Web Apps - .NET Conf CO 2017

PERO… ¿COMO LO LOGRAMOS?

Page 70: Progressive Web Apps - .NET Conf CO 2017

PERO… ¿COMO LO LOGRAMOS?

Page 71: Progressive Web Apps - .NET Conf CO 2017

{

"lang": "en",

"short_name": "My App",

"name": "My Totally Awesome App",

"icons": [

{

"src": "img/launcher-icon-2x.png",

"sizes": "96x96",

"type": "image/png"

}, {

"src": "img/launcher-icon-4x.png",

"sizes": "192x192",

"type": "image/png"

}

],

"start_url": "/pwa/?utm_source=homescreen",

"display": "standalone",

"orientation": "portrait",

"background_color": "black"

}

WEB APP

MANIFESTMeta Tags 2.0

Page 72: Progressive Web Apps - .NET Conf CO 2017

SERVICE

WORKERActua como servidor proxy

entre la web app, el browser

y la conexión (cuando está

disponible)

Page 73: Progressive Web Apps - .NET Conf CO 2017

Solo HTTPS

No tiene acceso al DOM

Solo request asyncronicos

Ejecuta separado del sitio

Un service worker por alcance

SERVICE WORKERS

PROPIEDADES

Page 74: Progressive Web Apps - .NET Conf CO 2017

PERO… ¿PUEDO USARLO?

Page 75: Progressive Web Apps - .NET Conf CO 2017

PERO… ¿PUEDO USARLO?

Page 76: Progressive Web Apps - .NET Conf CO 2017
Page 77: Progressive Web Apps - .NET Conf CO 2017

1. if ('serviceWorker' in navigator) {2. navigator.serviceWorker.register('/service-worker.js')3. .then(registration => {4. console.log('Registered:', registration);5. })6. .catch(error => {7. console.log('Registration failed: ', error);8. });9. }

index.html

Page 78: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 79: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 80: Progressive Web Apps - .NET Conf CO 2017

1. self.addEventListener('install', event => {2. event.waitUntil(3. caches.open('static-v1').then(cache => {4. return cache.addAll([5. '/',6. '/index.html',7. '/styles.css',8. '/main.js',9. '/fallback.html'10. ]);11. })12. );13. }

sw.js

Page 81: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 82: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 83: Progressive Web Apps - .NET Conf CO 2017

1. self.addEventListener('activate', event => {2. var keepList = ['assets-v1'];3.4. event.waitUntil(5. caches.keys().then(cacheNameList => {6. return Promise.all(cacheNameList7. .map(cacheName => { 8. if (keepList.indexOf(cacheName) === -1) {9. return caches.delete(cacheName);10. }11. }));12. })13. );14. }

sw.js

Page 84: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 85: Progressive Web Apps - .NET Conf CO 2017

CICLO DE VIDA

Page 86: Progressive Web Apps - .NET Conf CO 2017

1. self.addEventListener('fetch', event => {2. event.respondWith(3. caches.match(event.request).then(response => {4. return response || fetch(event.request)5. .catch(() => {6. return caches.match('/fallback.htm1');7. });8. })9. );10. }

sw.js

Page 87: Progressive Web Apps - .NET Conf CO 2017
Page 88: Progressive Web Apps - .NET Conf CO 2017

CACHE APIS

Page 89: Progressive Web Apps - .NET Conf CO 2017
Page 90: Progressive Web Apps - .NET Conf CO 2017

CACHES API

ANATOMY

REQUEST(URL) RESPONSE

https://wea.app/index.html <!doctype html>

https://wea.app/script.js console.log('hi')

...

key / value storage

Page 91: Progressive Web Apps - .NET Conf CO 2017

Cache APIURL-addressable resources

-----or -----

Indexed DBOther data

Page 92: Progressive Web Apps - .NET Conf CO 2017

PUSH NOTIFICATIONS

Page 93: Progressive Web Apps - .NET Conf CO 2017

1. navigator.serviceWorker.register('sw.js')2. .then(reg => {3. return reg.pushManager.getSubscription()4. .then(subscription => {5. if (subscription) return subscription;

6. return registration.pushManager.subscribe({7. userVisibleOnly: true, 8. applicationServerKey: appPubkey9. });10. });11. })

index.html

Page 94: Progressive Web Apps - .NET Conf CO 2017

1. self.addEventListener('push', event => {2. var payload = event.data ?3. event.data.text() : 'no payload';4. event.waitUntil(5. registration.showNotification('WEATHER ADVISORY', {6. body: payload,7. icon: 'icon.png'8. })9. );10. }

sw.js

Page 95: Progressive Web Apps - .NET Conf CO 2017

1. self.addEventListener('notificationclick', event => {2. event.notification.close();3. event.waitUntil(clients4. .openWindow('https://wea.app/advisory'));5. }

sw.js

Page 96: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APPS

EN WINDOWS

Page 97: Progressive Web Apps - .NET Conf CO 2017

¿COMO HACE UN USUARIO PARA

ENCONTRAR UNA PROGRESSIVE

WEB APP?

Page 98: Progressive Web Apps - .NET Conf CO 2017

AHORA MISMO: STORE & BING

Page 99: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APPS

¿¡¿EN WINDOWS STORE?!?

Page 100: Progressive Web Apps - .NET Conf CO 2017

PROGRESSIVE WEB APPS

¿¡¿EN WINDOWS STORE?!?

Page 101: Progressive Web Apps - .NET Conf CO 2017

PWAS EN WINDOWS STORE

• Presentación activa

Page 102: Progressive Web Apps - .NET Conf CO 2017

PWAS EN WINDOWS STORE

• Presentación activa

• Ingestión Pasiva

No hacer nada y Microsoft va a agregar tu PWA

automaticamente *

* Se puede no hacerlo usando robots.txt

Page 103: Progressive Web Apps - .NET Conf CO 2017

ANULANDO CON ROBOTS.TXT

Page 104: Progressive Web Apps - .NET Conf CO 2017

PWAS EN LOS STORES

app.manifest

popula la

entrada:

1. name

2. description

3. icons

4. screenshots

Page 105: Progressive Web Apps - .NET Conf CO 2017

DESDE LA PERSPECTIVA DEL

USUARIO,

UNA PWA VA A SER UNA APP.

Page 106: Progressive Web Apps - .NET Conf CO 2017

¡A NUESTROS USUARIOS NO LES

INTERESA QUE TECNOLOGIA

USAMOS!

Quieren usar nuestra app

Page 107: Progressive Web Apps - .NET Conf CO 2017

UNA PWA ES SUPER SIMPLE DE

HACER Y LOS BENEFICIOS SON

IMPORTANTES.

Page 108: Progressive Web Apps - .NET Conf CO 2017

BIT.LY/

PWA-WORKSHOP-NETCONFGithub: https://github.com/PWA-espanol/workshop

Page 109: Progressive Web Apps - .NET Conf CO 2017

¡MUCHAS GRACIAS!@nbellocam

Page 110: Progressive Web Apps - .NET Conf CO 2017

¿Preguntas?