Top Banner
in the #YearOfPWA in the #YearOfPWA Maxim Salnikov @webmaxru Progressive Progressive Angular Apps Angular Apps
117

Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

May 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

in the #YearOfPWAin the #YearOfPWA

Maxim Salnikov@webmaxru

ProgressiveProgressiveAngular AppsAngular Apps

Page 2: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

“ How to create AngularHow to create AngularProgressive Web App?Progressive Web App?

Page 3: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

“ How to create AngularHow to create AngularProgressive Web App?Progressive Web App?

Using the native toolsUsing the native tools

Page 4: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Maxim SalnikovMaxim Salnikov

@webmaxru@webmaxru

Google Developer Expert, Microsoft MVPGoogle Developer Expert, Microsoft MVP

Angular Angular OsloOslo / / PWA OsloPWA Oslo meetups meetupsorganizerorganizer

ngVikingsngVikings  / / Mobile Era Mobile Era conferencesconferencesorganizerorganizer

“ Products from the futureUI Engineer at ForgeRock

Page 5: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

After all, what is PWA?After all, what is PWA?

Page 6: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

After all, what is PWA?After all, what is PWA?

Progressive web apps use modern web APIs alongwith traditional progressive enhancement strategyto create cross-platform web applications.

https://developer.mozilla.org/en-US/Apps/Progressive

Page 7: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

After all, what is PWA?After all, what is PWA?

Progressive web apps use modern web APIs alongwith traditional progressive enhancement strategyto create cross-platform web applications.

https://developer.mozilla.org/en-US/Apps/Progressive

These apps work These apps work everywhereeverywhere and provide and provideseveral features that give them the sameseveral features that give them the sameuser experience advantagesuser experience advantages as native apps. as native apps.

Page 8: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

#YearOfPWA#YearOfPWA

Page 9: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

#YearOfPWA#YearOfPWA

Latest updatesLatest updates

Page 10: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

Page 11: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

Page 12: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

MobileMobile

Page 13: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

DesktopDesktop

MobileMobile

Page 14: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

DesktopDesktop

MobileMobile

Page 15: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

DesktopDesktop

MobileMobile

Page 16: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

DesktopDesktop

MobileMobile

OS

Page 17: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Cross-platform?Cross-platform?

BrowserBrowser

DesktopDesktop

MobileMobile

Flagged

OS

Page 18: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Page 19: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Smart networking + OfflineSmart networking + Offline

Page 20: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Smart networking + OfflineSmart networking + Offline

Staying notifiedStaying notified

Page 21: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Smart networking + OfflineSmart networking + Offline

Staying notifiedStaying notified

Other cool thingsOther cool things

Page 22: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Smart networking + OfflineSmart networking + Offline

Staying notifiedStaying notified

Other cool thingsOther cool things}} Service Worker

API

Page 23: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

UX advantages?UX advantages?

Smart networking + OfflineSmart networking + Offline

Proper app experienceProper app experience

Staying notifiedStaying notified

Other cool thingsOther cool things}} Service Worker

API

Web App Manifest

Page 24: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

❤❤

Page 25: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Create Angular PWACreate Angular PWA

Page 26: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Create Angular PWACreate Angular PWA

Code service worker Code service worker manuallymanually

Page 27: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Create Angular PWACreate Angular PWA

Code service worker Code service worker manuallymanually

Use framework-agnostic Use framework-agnostic PWA librariesPWA libraries

Page 28: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Create Angular PWACreate Angular PWA

Code service worker Code service worker manuallymanually

Use framework-agnostic Use framework-agnostic PWA librariesPWA libraries

Use Angular Service Worker (Use Angular Service Worker (NGSWNGSW))

Page 29: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Automate it!Automate it!

Page 30: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

PWA MVPPWA MVP

Recipe #1Recipe #1

Page 31: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Page 32: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Served via HTTPSServed via HTTPS

Page 33: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Served via HTTPSServed via HTTPS

Responsive, fast, cross-browserResponsive, fast, cross-browser

Page 34: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Served via HTTPSServed via HTTPS

Responsive, fast, cross-browserResponsive, fast, cross-browser

App metadata providedApp metadata provided

Page 35: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Served via HTTPSServed via HTTPS

Responsive, fast, cross-browserResponsive, fast, cross-browser

App metadata providedApp metadata provided

App loads while offlineApp loads while offline

Page 36: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Minimal PWAMinimal PWA

Served via HTTPSServed via HTTPS

Responsive, fast, cross-browserResponsive, fast, cross-browser

App metadata providedApp metadata provided

App loads while offlineApp loads while offline }} PWA schematicsPWA schematics

Page 37: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Apply PWA schematicsApply PWA schematics

Page 38: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

$ ng add @angular/pwa

Apply PWA schematicsApply PWA schematics

Page 39: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

$ ng add @angular/pwa

$ ng build --prod

Apply PWA schematicsApply PWA schematics

Page 40: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

$ ng add @angular/pwa

$ ng build --prod

Apply PWA schematicsApply PWA schematics

ngsw-worker.jsngsw-worker.js

ngsw.jsonngsw.json

dist/project-namedist/project-name

Page 41: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

$ ng add @angular/pwa

$ ng build --prod

Apply PWA schematicsApply PWA schematics

ngsw-worker.jsngsw-worker.js

ngsw.jsonngsw.json

dist/project-namedist/project-name

assets/icons/*.pngassets/icons/*.png

manifest.jsonmanifest.json

Page 42: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

$ ng add @angular/pwa

$ ng build --prod

Apply PWA schematicsApply PWA schematics

ngsw-worker.jsngsw-worker.js

ngsw.jsonngsw.json

dist/project-namedist/project-name

safety-worker.jssafety-worker.js

assets/icons/*.pngassets/icons/*.png

manifest.jsonmanifest.json

worker-basic.min.jsworker-basic.min.js

Page 43: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Running and auditingRunning and auditing

Page 44: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Running and auditingRunning and auditing

$ ng serve --prod

Page 45: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Running and auditingRunning and auditing

$ ng serve --prod

Page 46: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Running and auditingRunning and auditing

$ ng serve --prod

Page 47: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Running and auditingRunning and auditing

$ ng serve --prod

Page 48: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

 

Page 49: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

 

Page 50: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

Register service workerRegister service worker

 

Page 51: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

Register service workerRegister service worker

Load and cache assetsLoad and cache assets

 

Page 52: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

Register service workerRegister service worker

Load and cache assetsLoad and cache assets

Set up routingSet up routing

 

Page 53: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

Register service workerRegister service worker

Load and cache assetsLoad and cache assets

Set up routingSet up routing

Serve assets from the Cache StorageServe assets from the Cache Storage

 

Page 54: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell actionsApp shell actions

Generate assets Generate assets (+ hashes)(+ hashes) list list

Register service workerRegister service worker

Load and cache assetsLoad and cache assets

Set up routingSet up routing

Serve assets from the Cache StorageServe assets from the Cache Storage

Load and cache the updated assetsLoad and cache the updated assets

 

Page 55: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

NGSW configuration fileNGSW configuration file

Page 56: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

NGSW configuration fileNGSW configuration file

ngsw-config.jsonngsw-config.json

{ "index": "/index.html", "assetGroups": [...], "dataGroups": [...] }

Page 57: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shellApp shell

Page 58: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shellApp shell

assetGroupsassetGroups

{ "name": "app", "installMode": "prefetch", "resources": {...} }

Page 59: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell resourcesApp shell resources

assetGroups / "app" / resourcesassetGroups / "app" / resources

"resources": { }

Page 60: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell resourcesApp shell resources

assetGroups / "app" / resourcesassetGroups / "app" / resources

"resources": { }

"files": [ "/favicon.ico", "/index.html", "/*.css", "/*.js" ]

Page 61: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Important!Important!

src/src/

Page 62: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Important!Important!

src/src/

manifest.jsonmanifest.json

Page 63: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Important!Important!

src/src/

assets/icons/*.pngassets/icons/*.png

manifest.jsonmanifest.json

Page 64: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Important!Important!

src/src/

assets/icons/*.pngassets/icons/*.png

manifest.jsonmanifest.json

index.html / <meta name="theme-color" ...>index.html / <meta name="theme-color" ...>

Page 65: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Important!Important!

src/src/

assets/icons/*.pngassets/icons/*.png

manifest.jsonmanifest.json

index.html / <meta name="theme-color" ...>index.html / <meta name="theme-color" ...>

To be customizedTo be customized

Page 66: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Add more resources to theAdd more resources to theApp ShellApp Shell

Recipe #2Recipe #2

Page 67: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell / on-demandApp shell / on-demand

Page 68: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell / on-demandApp shell / on-demand

assetGroupsassetGroups

{ "name": "assets", "installMode": "lazy", "updateMode": "prefetch", "resources": {...} }

Page 69: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell / on-demandApp shell / on-demand

assetGroups / "assets" / resourcesassetGroups / "assets" / resources

"resources": { }

Page 70: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell / on-demandApp shell / on-demand

assetGroups / "assets" / resourcesassetGroups / "assets" / resources

"resources": { }

"files": [ "/assets/**" ],

Page 71: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App shell / on-demandApp shell / on-demand

assetGroups / "assets" / resourcesassetGroups / "assets" / resources

"resources": { }

"files": [ "/assets/**" ],

"urls": [ "https://fonts.googleapis.com/**", "https://fonts.gstatic.com/**" ]

Page 72: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Data requests cachingData requests caching

Recipe #3Recipe #3

Page 73: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Runtime cachingRuntime caching

Page 74: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Runtime cachingRuntime caching

dataGroupsdataGroups

{ "name": "api-freshness", "urls": [ "/api/breakingnews/**" ], }

Page 75: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Runtime cachingRuntime caching

dataGroupsdataGroups

{ "name": "api-freshness", "urls": [ "/api/breakingnews/**" ], }

"cacheConfig": { "strategy": "freshness", "maxSize": 10, "maxAge": "12h", "timeout": "10s" }

Page 76: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Runtime cachingRuntime caching

dataGroupsdataGroups

{ "name": "api-performance", "urls": [ "/api/archive/**" ], }

Page 77: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Runtime cachingRuntime caching

dataGroupsdataGroups

{ "name": "api-performance", "urls": [ "/api/archive/**" ], }

"cacheConfig": { "strategy": "performance", "maxSize": 100, "maxAge": "365d" }

Page 78: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Support API versioningSupport API versioning

Recipe #4Recipe #4

Page 79: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Support API versioningSupport API versioning

dataGroupsdataGroups

{ "version": 1, "name": "api-performance", "urls": [ "/api/**" ], ... }

Page 80: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Support API versioningSupport API versioning

dataGroupsdataGroups

{ "version": 1, "name": "api-performance", "urls": [ "/api/**" ], ... }

{ "version": 2, "name": "api-performance", "urls": [ "/api/**" ], ... }

Page 81: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App update notificationsApp update notifications

Recipe #5Recipe #5

Page 82: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App version updatesApp version updates

v1v1

v1v1

ServerServer

BrowserBrowser

Page 83: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App version updatesApp version updates

v1v1 v2v2

v1v1

ServerServer

BrowserBrowser

Page 84: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App version updatesApp version updates

v1v1 v2v2

v1v1v1v1

ServerServer

BrowserBrowser

Page 85: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App version updatesApp version updates

v1v1 v2v2

v1v1v1v1 v2v2

ServerServer

BrowserBrowser

v2v2

Page 86: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

App version updatesApp version updates

v1v1 v2v2

v1v1v1v1 v2v2

ServerServer

BrowserBrowser

v2v2

Page 87: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Notify about updatesNotify about updates

Page 88: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Notify about updatesNotify about updates

import { SwUpdate } from '@angular/service-worker';

updates.component.tsupdates.component.ts

Page 89: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Notify about updatesNotify about updates

import { SwUpdate } from '@angular/service-worker';

constructor(updates: SwUpdate) {}

updates.component.tsupdates.component.ts

Page 90: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Notify about updatesNotify about updates

import { SwUpdate } from '@angular/service-worker';

constructor(updates: SwUpdate) {}

this.updates.available.subscribe(event => { })

updates.component.tsupdates.component.ts

Page 91: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Notify about updatesNotify about updates

import { SwUpdate } from '@angular/service-worker';

constructor(updates: SwUpdate) {}

this.updates.available.subscribe(event => { })

updates.component.tsupdates.component.ts

if (confirm(`New Version is available! OK to refresh`)) { window.location.reload(); }

Page 92: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform
Page 93: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Subscribing for the PushSubscribing for the Pushnotificationsnotifications

Recipe #6Recipe #6

Page 94: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notificationsPush notifications

Page 95: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notificationsPush notifications

import { SwPush } from '@angular/service-worker';

push.component.tspush.component.ts

Page 96: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notificationsPush notifications

import { SwPush } from '@angular/service-worker';

constructor(push: SwPush) {}

push.component.tspush.component.ts

Page 97: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notificationsPush notifications

import { SwPush } from '@angular/service-worker';

constructor(push: SwPush) {}

subscribeToPush() { this.push.requestSubscription({ serverPublicKey: this.VAPID_PUBLIC_KEY }) .then(pushSubscription => { // Pass subscription object to the backend }) }

push.component.tspush.component.ts

Page 98: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notifications / sendPush notifications / send

Page 99: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notifications / sendPush notifications / send

{ "notification": { } }

server-side.js / sendNotification payloadserver-side.js / sendNotification payload

Page 100: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Push notifications / sendPush notifications / send

{ "notification": { } }

server-side.js / sendNotification payloadserver-side.js / sendNotification payload

"title": "Very important notification", "body": "Angular Service Worker is cool!", "icon": "https://angular.io/assets/logo.png", "actions": [ { "action": "gocheck", "title": "Go and check" } ], ...

Page 101: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform
Page 102: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Main available featuresMain available features

Page 103: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Main available featuresMain available features

App shell withApp shell with

automatic updatesautomatic updates

Page 104: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Main available featuresMain available features

App shell withApp shell with

automatic updatesautomatic updatesRuntime data cachingRuntime data caching

Page 105: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Main available featuresMain available features

App shell withApp shell with

automatic updatesautomatic updatesRuntime data cachingRuntime data caching

Push notificationsPush notificationssubscription and displaysubscription and display

Page 106: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Main available featuresMain available features

App shell withApp shell with

automatic updatesautomatic updatesRuntime data cachingRuntime data caching

Push notificationsPush notificationssubscription and displaysubscription and display Debugger and kill switchDebugger and kill switch

Page 107: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros ConsCons

 

Page 108: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros

Minimal PWA goesMinimal PWA goesout-of-the-boxout-of-the-box

ConsCons

 

Page 109: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros

Minimal PWA goesMinimal PWA goesout-of-the-boxout-of-the-box

Essential features areEssential features arecodelesscodeless

ConsCons

 

Page 110: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros

Minimal PWA goesMinimal PWA goesout-of-the-boxout-of-the-box

Essential features areEssential features arecodelesscodeless

Doing things inDoing things inAngular wayAngular way

ConsCons

 

Page 111: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros

Minimal PWA goesMinimal PWA goesout-of-the-boxout-of-the-box

Essential features areEssential features arecodelesscodeless

Doing things inDoing things inAngular wayAngular way

ConsCons

Intended to play a mainIntended to play a mainservice worker's role inservice worker's role inyour PWAyour PWA

 

Page 112: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

ProsPros

Minimal PWA goesMinimal PWA goesout-of-the-boxout-of-the-box

Essential features areEssential features arecodelesscodeless

Doing things inDoing things inAngular wayAngular way

ConsCons

Intended to play a mainIntended to play a mainservice worker's role inservice worker's role inyour PWAyour PWA

There is no way to extendThere is no way to extendthe functionalitythe functionality

 

Page 113: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

bit.ly/go-pwa-slackbit.ly/go-pwa-slack

Page 114: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

1700+ developers1700+ developers

bit.ly/go-pwa-slackbit.ly/go-pwa-slack

Page 115: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

1700+ developers1700+ developers

Major browsers/frameworks/libs repsMajor browsers/frameworks/libs reps

bit.ly/go-pwa-slackbit.ly/go-pwa-slack

Page 116: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Thank you!Thank you!

Maxim Salnikov@webmaxru

Page 117: Progressive Angular Apps - Microsoft...After all, wha t is PWA? Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform

Questions?Questions?