Más contenido relacionado Similar a Progressive Web Apps - .NET Conf CO 2017 (20) Más de Nicolás Bello Camilletti (16) Progressive Web Apps - .NET Conf CO 201725. PWAS=MENORCOSTO(&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
Nativa
Es requerido publicar en los App store
71. {
"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"
}
WEBAPP
MANIFEST
Meta Tags 2.0
73. Solo HTTPS
No tiene acceso al DOM
Solo request asyncronicos
Ejecuta separado del sitio
Un service worker por alcance
SERVICE WORKERS
PROPIEDADES
77. 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
80. 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
83. 1. self.addEventListener('activate', event => {
2. var keepList = ['assets-v1'];
3.
4. event.waitUntil(
5. caches.keys().then(cacheNameList => {
6. return Promise.all(cacheNameList
7. .map(cacheName => {
8. if (keepList.indexOf(cacheName) === -1) {
9. return caches.delete(cacheName);
10. }
11. }));
12. })
13. );
14. }
sw.js
86. 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
93. 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: appPubkey
9. });
10. });
11. })
index.html
94. 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