Index

Symbols

' (single quotation mark), 30

. (period), 209, 215

` (back tick), 30

A

<a> tag, target attribute, 25

abort method, 108

actions property, 145

actionsContainer div, 176

activate event listener, 58, 61, 8081

activating service workers, 59, 6263

Add Features pane (PWABuilder), 193

add method, 68

Add to Home Screen option, 1115

addAll method, 68, 71

addEventListener method, 64, 71, 168, 169171

admin.js files (push notification app), 154

Air Horner app, 10

all method, 120, 121

Amazon sync SDKs, 103

Android devices. See also remote notifications

installing web apps on

Add to Home Screen option, 1115

with manifest files. See web app manifest files

notifications on, 129130

Angular, 7

Apache Cordova, 3, 7

APIs (application programming interfaces), Push API, 4951, 134

api.ts file, 162164

app stores, 7

AppCache, 4546

appinstalled event listener, 39

Apple Dashcode, 3

Apple iOS devices

installing web apps on

Add to Home Screen option, 1115

with manifest files. See web app manifest files

iPhone, 3

push notifications, lack of support for, 129

Application Cache, 4546

application resource caching. See caching

applicationServerKey, 148149

apps, converting into PWAs

deployable apps, creating, 195196

overview of, 190191

PWABuilder CLI, 197

PWABuilder UI, 191195

Add Features pane, 193

home page, 191192

Manifest Editor page, 193194

scan results, 192

Service Worker page, 194195

Visual Studio PWABuilder extension, 198202

command palette, 198199

generated manifest files, 200201

installing, 198

Manifest Generator page, 199200

Archibald, Jake, 45

arrays, urlList, 7071

assessing quality

Chrome Lighthouse tools, 187189

coding preparation, 182

Lighthouse node module, 189190

Lighthouse plug-in, 182187

overview of, 181182

automation, service worker

overview of, 207208

precaching service workers

adding precaching to existing service workers, 215218

cache strategies, controlling, 218224

generating, 208214

Azure

Bing News Search API, 4951

free plan, 50

B

back tick (`), 30

background sync

capabilities of, 99103

data objects

adding to stores, 107108

deleting from stores, 108109

iterating through, 109110

databases

choosing, 105

creating, 105106

offline data sync, 103105

poke-and-pull method, 104105

PWA News Feedback page

db.js file, 114117, 122124

install event listener, 119

last chances, 125128

onupgradeneeded callback, 116

openIDB function, 113, 115116

postFeedback function, 112113

preparing service workers for, 111112

queueFeedback function, 116117

refresh on success, 117

service worker preparation, 111112

service worker queue processing, 119125

software prerequisites, 110111

submitFeedback function, 112, 113114

testing, 118119

software prerequisites, 110111

store creation, 107

tags and, 102103

background tasks, 3

background_color property, 25

backslash (), 69

badge property, 145

beforeinstallprompt event, 36, 131

Berriman, Frances, 2

Bing News Search API, 4951

BING_ACCESS_KEY property, 5051

body property, 145147

browser display mode, 2223

browsers. See also remote notifications

applying service workers to, 6364

service worker support, 4445

web app manifest support, 16

C

Cache interface, 6768

Cache Storage (Chrome), 7477

CACHE_ROOT constant, 80

cacheableResponse plugin, 223

CacheFirst strategy, 219

CacheOnly strategy, 9293, 219

CacheStorage API, 46

caching

AppCache, 4546

Cache interface, 6768

cache management, 7677

activate event listener, 8081

CACHE_ROOT constant, 80

custom cache generation, 79

deletion of cache, 78, 7980

service worker version number, 78

sw-42.js file, 8183

CacheStorage API, 46

enabling, 7077

fetch event listener, 72

install event listener, 7172

sw-41.js file, 7274

urlList array, 7071

offline awareness, 77

offline pages, creating, 8691

overview of, 67

precaching service workers

adding precaching to existing service workers, 215218

cache strategies, controlling, 218224

generating, 208214

overview of, 207208

returning data object on error, 8386

strategies for, 9192

cache-only, 9293

network-first, cache-next, 9394

network-first, update-cache, 9498

callbacks

callback hell, 68

onclose, 106

onerror, 106

onsuccess, 106

onupgradeneeded, 107, 116

Can I Use website, 16, 4445

capabilities of PWAs (Progressive Web Apps), 46

catch method, 53

characteristics of PWAs (Progressive Web Apps), 24

Chrome

Cache Storage, 7477

Developer Tools Application Tab, 55

Lighthouse tools in, 187189

PWAs, installing/removing, 36

Service Worker Internals Page, 56

service workers

listing registered, 5556

support for, 4445

shortcuts, 11

CLI (command-line interface), PWABuilder, 197

clients, Git, 2829, 4748

client-side scripting, 45

color options, configuring, 25

commands

copy-config, 51, 69, 110

git clone, 28, 48

git --version, 28, 47

http-server, 28, 33, 182, 212

node generate-keys.js, 135, 166

node -v, 28, 47

npm install, 48, 69, 110, 134, 166

npm install -g lighthouse, 189

npm install -g pwabuilder, 197

npm install -g typescript, 47

npm install -g workbox-cli, 208

npm install http-server -g, 28

npm install workbox-cli -global, 215

npm start, 51, 110, 136, 166

pwabuilder, 197

tsc, 49, 51, 69, 110, 166

workbox injectManifest, 217

workbox wizard, 208

workbox wizard -injectManifest, 215

community-driven logo (PWA), 1

compilers. See TypeScript

configuration files

push notification app, 135

PWA News web app, 50, 51, 69, 110

workbox-config.js file, 210, 213

configuration of web apps

app icons, 1819

app name, 18

color options, 25

display mode, 1923

browser, 2223

fullscreen, 1920

minimal-ui, 2122

standalone, 2021

installation process, 2627

orientation, 2526

server APIs, 4951

start URL, 2325, 39

theme color, 25

controllerchange event, 64

controlling cache strategies, 218224

cacheableResponse plugin, 223

default cache, 223224

route registration and matching, 219

supported strategies, 219

copy-config command, 51, 69, 110

Cordova (Apache), 3

CORS (cross-origin resource sharing), 98

Couchbase, 103

cross-origin resource sharing (CORS), 98

cursors, iterating through data with, 109110

custom cache, generating, 79

D

data communication

coding preparation, 166167

overview of, 165166

sending data from service worker to web app window, 169171

sending data from web app to service worker, 167168

event handling, 168

postMessage method, 167168

web app output, 168

two-way communication with MessageChannel, 171179

click event listener, 171172

message channels, creating, 171172

data objects

adding to stores, 107108

deleting from stores, 108109

iterating through, 109110

returning on error, 8386

data property, 145

databases, sync

choosing, 105

creating, 105106

stores

adding data to, 107108

creating, 107

deleting data from, 108109

iterating through, 109110

data.items.map method, 120, 121

db.js file, 114117, 119, 122124

default cache, 223224

default permission value, 138

deferredPrompt object, 36

delete method, 68

deleteFeedback function, 120, 121, 123124

deleting

caching, 78, 7980

data objects from stores, 108109

denied permission value, 138

deployment

to app stores, 7

deployable apps, creating, 195196

PWAs (Progressive Web Apps), 202205

DevTools, Chrome. See Chrome

dir property, 145

display mode, configuring with web app manifest files, 1923

browser, 2223

fullscreen, 1920

minimal-ui, 2122

standalone, 2021

display property, 1923

document object model (DOM), service worker access to, 46

doInstall function, 37

doLongAction function, 176177

DOM (document object model), service worker access to, 46

domains, obtaining, 35

doPlayback function, 173

doSubscribe function, 142, 151152, 167

doUnsubscribe function, 154155, 167

E

Edge, 4445

EMPTY_NEWS_OBJECT constant, 83

enabling resource caching, 7077

fetch event listener, 72

install event listener, 7172

sw-41.js file, 7274

urlList array, 7071

encryption keys, generating, 134137

encryption of remote notifications, 133

enhancement, progressive, 4

errors

returning data objects on, 8386

returning text/HTML content on, 8791

Workbox, 214

events and event listeners, 39, 84

activate, 58, 61, 8081

beforeinstallprompt, 36, 131

controllerchange, 64

fetch, 55

cache-only strategy in, 9293

caching, enabling, 72

data object, returning on error, 8486

network-first, cache-next strategy in, 9394

network-first, update-cache strategy in, 9496

text/HTML content, returning on error, 8791

install

caching, enabling, 7172

install event listener, 119

service worker lifestyle, 61

service worker registration, 58

message, 168, 172, 173175, 177179

notificationclick, 157

pushsubscriptionchange, 162

sync. See also background sync

registering, 102103

triggering, 102

expired subscriptions, 162

exponential fallback algorithm, 125128

Express, 47

F

Feedback Page (PWA News web app), 99

db.js file, 114117, 119, 122124

Feedback Page, 99

install event listener, 119

last chances, 125128

onupgradeneeded callback, 116

openIDB function, 113, 115116

postFeedback function, 112113

preparing service workers for, 111112

queueFeedback function, 116117

refresh on success, 117

service worker preparation, 111112

service worker queue processing, 119125

software prerequisites, 110111

submitFeedback function, 112, 113114

testing, 118119

fetch event listener, 55, 84

cache-only strategy in, 9293

caching, enabling, 72

data object, returning on error, 8486

network-first, cache-next strategy in, 9394

network-first, update-cache strategy in, 9496

text/HTML content, returning on error, 8791

fetch function, 120, 121

fetchWrapper.mjs file, 221

Firebase, 103

Firefox, 4445

folders, selecting for precaching, 209, 215

forcing

service worker activation, 6263

service worker updates, 6466

forward slash (/), 69

fullscreen display mode, 1920

G

Gaunt, Matt, 16

GCM (Google Cloud Messaging), 136

GCMAPI_KEY, 136

generateVAPIDKeys method, 135, 166

getFeedbackItems function, 120, 121, 122123

Git client, installing, 2829, 4748

git clone command, 28, 48

git --version command, 28, 47

GitHub

Air Horner app, 10

Electron, 7

HTTP Server app, 28

Learning PWA Code repository, 10, 28, 69, 110, 134, 166

Web App Manifest Generator, 42

globIgnores property, 213

Good, Scott, 10, 134, 160

Google

Air Horner app, 10

Chrome

Cache Storage, 7477

Developer Tools Application Tab, 55

Lighthouse tools in, 187189

PWA support, 2

Service Worker Internals Page, 56

service workers, listing registered, 5556

service workers, support for, 4445

Domains, 35

GCM (Google Cloud Messaging), 136

Google Play Store, 7

Lighthouse. See Lighthouse

Play Store, 7

TWA (Trusted Web Activity), 7

Workbox. See Workbox

granted permission value, 138

H

headers, max-age, 97

history of PWAs (Progressive Web Apps), 26

HTML content, returning on error, 8791

HTML5 Boilerplate template, 136

HTTP Server app, 28

HTTPS (Hypertext Transfer Protocol Secure), 4

http-server command, 28, 33, 182, 212

Hypertext Transfer Protocol Secure (HTTPS), 4

I

icon property, 145147

icons

defining, 1819

notification, 145147

icons property, 1819

id property, 169

image property, 145147

images, notifications and, 145147

IndexedDB

advantages of, 105

database creation, 105106

open method, 106

stores

adding data to, 107108

creating, 107

deleting data from, 108109

iterating through, 109110

index.html file

PWA News web app, 52

Tip Calculator app, 3133, 3536

Install button (Tip Calculator app)

appinstalled event listener, 39

beforeinstallprompt event listener, 36

deferredPrompt object, 36

doInstall function, 37

installbutton variable, 36

preventDefault function, 36

install event listener

background sync, 119

caching, enabling, 7172

service worker lifestyle, 61

service worker registration, 58

installation

Git client, 2829, 4748

Node.js, 28, 47, 69, 110, 134

speed of, 3

TypeScript, 47

Visual Studio Code, 29, 48

Visual Studio PWABuilder extension, 198

web apps

with Add to Home Screen option, 1115

with manifest files. See web app manifest files

Workbox, 208

interfaces, Cache, 6768

Ionic Capacitor, 7

Ionic Framework, 7

iOS devices

installing web apps on

Add to Home Screen option, 1115

with manifest files. See web app manifest files

iPhone, 3

push notifications, lack of support for, 129

iterating through data, 109110

J

JavaScript, 45

callback hell, 68

.js files, compiling .ts files into, 49, 69, 110, 136

JSON (JavaScript Object Notation), 17

promises, 68

Jobs, Steve, 3

JSON (JavaScript Object Notation), 17

K

Keith, Jeremy, 2

keys, encryption, 134137

keys method, 68

Kinlan, Paul, 16

L

lang property, 145

last chances, background sync, 125128

lastChance property, 125128

Learning PWA Code GitHub repository, 10, 28, 69, 110, 134, 166

libraries, pwcompat, 42

lifecycle, service worker, 6062

Lighthouse

Chrome tools, 187189

coding preparation, 182

Lighthouse plug-in, 182187

node module, 189190

overview of, 181182

<link> tag, 17

linking web app manifest files, 17, 3133

Live Data in the Service Worker, 105

local notifications, 142143

logo (PWA), 1

M

macOS computer, notifications on, 129130. See also remote notifications

main.js file (Tip Calculator app), 36, 37, 3941

management, cache, 7883

activate event listener, 8081

CACHE_ROOT constant, 80

custom cache generation, 79

deleting cache, 78, 7980

service worker version number, 78

sw-42.js file, 8183

Manifest Editor page (PWABuilder), 193194

manifest files. See web app manifest files

Manifest Generator page (Visual Studio PWABuilder extension), 199200

ManifoldJS, 191, 197

market impact, 67

match method, 68, 72

matchAll method, 68, 170

max-age header, 97

message channels

actionsContainer div, 176

browser long action results, 179

creating, 171172

doLongAction function, 176177

doPlayback function, 173

message event listener, 172, 173175, 177179

message event, 168, 172, 173175, 177179

MessageChannel interface, 171179

actionsContainer div, 176

browser long action results, 179

doLongAction function, 176177

doPlayback function, 173

message channels, creating, 171172

message event listener, 172, 173175, 177179

methods. See functions and methods

Microsoft

Azure

Bing News Search API, 4951

free plan, 50

Edge, 4445

ManifoldJS, 191, 197

Microsoft Store, 7, 202205

PWABuilder. See PWABuilder

minimal-ui display mode, 2122

modules, node, 70, 189190

Mozilla Firefox, 4445

N

name value, 18

names, defining, 18

network-first, cache-next strategy, 9394

network-first, update-cache strategy, 9498

NetworkFirst strategy, 219

NetworkOnly strategy, 219

node generate-keys.js command, 135, 166

node modules, 70, 189190

Node Package Manager (npm), 48, 69, 110, 134

node server, restarting automatically, 70

node -v command, 28, 47

Node.js, installing, 28, 47, 69, 110, 134

nodemon, 70

Notification object

checking for, 138

event handling, 142143

permission property, 138

requestPermission method, 139140

showNotification method, 144

notificationclick event, 157

notifications

local, 142143

overview of, 129131

remote (push), 3

browser support for, 129

in-browser testing, 156157

coding preparation, 134

definition of, 129

encryption keys, generating, 134137

encryption of, 133

local notifications versus, 142143

options for, 144147

overview of, 129131

permissions, 131, 138142

Postman, 158159

receiving, 156158

remote notification architecture, 132134

sending, 159161, 162164

subscribing to, 148154

subscription expiration, 162

unsubscribing from, 154156

validating support for, 138

web-push module, 162164

O

objects

data

adding to stores, 107108

deleting from stores, 108109

iterating through, 109110

returning on error, 8386

deferredPrompt, 36

Notification

checking for, 138

event handling, 142143

permission property, 138

requestPermission method, 139140

showNotification method, 144

options, 145

Response, 88

subOptions, 148

subscription, 149, 168

theDB, 106

transaction, 108

offline awareness, caching and, 77. See also background sync

offline data sync, 103105

offline pages, creating, 8691

Offline Storage for Progressive Web Apps, 105

onclose callback, 106

onerror callbacks, 106

onsuccess callbacks, 106

onupgradeneeded callback, 107, 116

open method, 106

openIDB function, 113, 115116

Opera, 4445

options object, 145

orientation, configuring, 2526

orientation property, 25

OrientationLockType, 26

P

passing data. See data communication

path delimiters, 69

performance, 3

period (.), 209, 215

permission property, 138

permissions, notification, 138142

checking, 138

obtaining, 139142

permission prompts, 131

PhoneGap project, 3

plug-ins, Lighthouse, 182187

poke-and-pull background sync, 104105

postFeedback function, 112113

Postman, 158159

postMessage method, 167168

postRegistration function, 150151

precacheAndRoute function, 212

precacheManifest, 212

precaching service workers

adding precaching to existing service workers, 215218

configuration files, 216217

folder selection, 215

sw.js file, 217218

cache strategies, controlling, 218224

cacheableResponse plugin, 223

default cache, 223224

route registration and matching, 219

supported strategies, 219

generating, 208214

configuration files, 210

error handling, 214

folder selection, 209

globIgnores property, 213

precacheAndRoute function, 212

precacheManifest, 212

sw.js file, 211

Workbox CLI, installing, 208

workbox-config.js file, 213

overview of, 207208

preventDefault function, 36

programmable network proxies. See service workers

progressive enhancement, 4

Promise.all method, 120, 121

promises (JavaScript), 68

properties

actions, 145

background_color, 25

badge, 145

BING_ACCESS_KEY, 5051

body, 145147

data, 145

dir, 145

display, 1923

icon, 145147

icons, 1819

image, 145147

lang, 145

lastChance, 125128

orientation, 25

permission, 138

ready, 66

renotify, 145

requireInteraction, 145

start_url, 2325, 39

tag, 145

theme_color, 25

VAPID_PUBLIC, 148149

vibrate, 145

Push API, 134

push notification app

admin.js files, 154

api.ts file, 162164

architecture for, 132134

in-browser testing, 156157

coding preparation, 134, 166167

data communication

sending data from service worker to web app window, 169171

sending data from web app to service worker, 167168

two-way communication with MessageChannel, 171179

index.js files, 142

index-61.js, 143

index-62.js, 154

index-63.js, 156

index-71.js, 171

index-72.js, 179

notifications

browser support for, 129

definition of, 129

encryption keys, generating, 134137

encryption of, 133

options, 144147

permissions, 131

receiving, 156158

sending, 159161, 162164

subscribing to, 148154

subscription expiration, 162

unsubscribing from, 154156

validating support for, 138

overview of, 129131

permissions, 138142

checking, 138

obtaining, 139142

Postman, 158159

remote notification architecture, 132134

service workers

service worker-71.js, 171

sw-63.js, 162

sw-72.js, 179

web-push module, 162164

push services, sending notifications to, 162164

pushsubscriptionchange event, 162

put method, 68

PWA Builder, 42

PWA Fire Developer, 42

PWA News web app

app source, 4849

automation with PWABuilder

deployable apps, creating, 195196

overview of, 190191

PWABuilder CLI, 197

PWABuilder UI, 191195

Visual Studio PWABuilder extension, 198202

caching

cache management, 7883

cache-only strategy, 9293

enabling, 7077

network-first, cache-next strategy, 9394

network-first, update-cache strategy, 9498

offline awareness, 77

offline pages, creating, 8691

returning data object on error, 8386

config.ts file, 5051, 69, 110, 135

db.js file, 114117, 119, 122124

Feedback page background sync, 99

db.js file, 114117, 119, 122124

Feedback Page, 99

install event listener, 119

last chances, 125128

onupgradeneeded callback, 116

openIDB function, 113, 115116

postFeedback function, 112113

preparing service workers for, 111112

queueFeedback function, 116117

refresh on success, 117

service worker preparation, 111112

service worker queue processing, 119125

software prerequisites, 110111

submitFeedback function, 112, 113114

testing, 118119

folder structure for, 4849

GitHub repository for, 69

index.html file, 52

online resources, 43

overview of, 43

server

server API configuration, 4951

starting, 5152

service workers

activation of, 59, 6263

applying to additional browser tabs, 6364

controllerchange event, 64

forcing updates of, 6466

index.html file, 52

lifecycle of, 6062

ready property, 66

registration of, 5259, 6566

scope of, 60

verifying in Chrome, 5556

version numbers, 78

software prerequisites, 4748

Git client, 4748

Node.js, 47

TypeScript, 47

Visual Studio Code, 48

utils.js file, 77

PWA Stats, 2

PWA Toolkit, 7

PWABuilder

CLI (command-line interface), 197

deployable apps, creating, 195196

overview of, 190191

UI (user interface), 191195

Add Features pane, 193

home page, 191192

Manifest Editor page, 193194

scan results, 192

Service Worker page, 194195

Visual Studio PWABuilder extension, 198202

command palette, 198199

generated manifest files, 200201

installing, 198

Manifest Generator page, 199200

pwabuilder command, 197

PWAs (Progressive Web Apps)

capabilities of, 46

characteristics of, 24

community-driven logo for, 1

definition of, 1

history of, 26

market impact of, 67

shell structure of, 45

pwcompat library, 42

Q

quality assessment

Chrome Lighthouse tools, 187189

coding preparation, 182

Lighthouse node module, 189190

Lighthouse plug-in, 182187

overview of, 181182

queue processing, 119125

queueFeedback function, 116117

quotation marks, single ('), 30

R

React apps

converting to PWAs, 67

definition of, 6

ready property, 66

receiving remote notifications, 154156

refresh on success, 117

register method, 53, 102

registering service workers

PWA News web app, 5259

forced updates, 6566

index.html file, 52

sw-34.js, 54

sw-35.js, 5657

sw-36.js, 57

sw-reg.js, 5354

verifying in Chrome, 5556

Tip Calculator app, 3033

registering sync events, 102103

registerRoute, 219

remote notifications, 3

architecture for, 132134

browser support for, 129

in-browser testing, 156157

coding preparation, 134

definition of, 129

encryption keys, generating, 134137

encryption of, 133

local notifications versus, 142143

options for, 144147

overview of, 129131

permissions, 138142

checking, 138

obtaining, 139142

permission prompts, 131

Postman, 158159

receiving, 156158

remote notification architecture, 132134

sending, 159161, 162164

subscribing to, 148154

doSubscribe function, 151152

postRegistration function, 151152

subscribe method, 148

subscription object, 149

updateUI function, 152153

urlBase64ToUint8Array function, 149

subscription expiration, 162

unsubscribing from, 154156

validating support for, 138

web-push module, 162164

removing PWAs (Progressive Web Apps), 36

renotify property, 145

requestPermission method, 139140

requireInteraction property, 145

resource caching. See caching

Response object, 88

restarting node server process, 70

returning data object on error, 8386

route registration, 219

Russell, Alex, 2

S

Safari, 3, 16, 4445

scope, service worker, 60

Secure VAPID key generator, 135137

sending notifications. See notifications

sendNotification method, 164

server (PWA News app)

server APIs, configuring, 4951

starting, 5152

Service Worker page (PWABuilder), 194195

service workers. See also push notification app; PWA News web app

activation of, 59, 6263

applying to additional browser tabs, 6364

browser support for, 4445

Cache interface, 6768

capabilities of, 4445

controllerchange event, 64

data communication with web apps

coding preparation, 166167

overview of, 165166

sending data from service worker to web app window, 169171

sending data from web app to service worker, 167168

two-way communication with MessageChannel, 171179

definition of, 44

install conditions, 44

lifecycle of, 6062

limitations of, 46

listing registered, 5556

precaching service workers

adding precaching to existing service workers, 215218

cache strategies, controlling, 218224

generating, 208214

overview of, 207208

preparing for background sync, 111112

queue processing, 119125

ready property, 66

registering

PWA News web app, 5259, 6566

Tip Calculator app, 3033

scope of, 60

software prerequisites, 4748

Git client, 4748

Node.js, 47

TypeScript, 47

Visual Studio Code, 48

updates, forcing, 6466

version numbers, 78

setDefaultHandler method, 223

short_name value, 18

shortcuts, creating in Chrome, 11

showNotification method, 144, 156

single page apps (SPAs), 9. See also Tip Calculator app

single quotation mark ('), 30

skipWaiting function, 119

sockets, WebSockets, 132

software prerequisites, 4748

background sync, 110111

Git client, 2829, 4748

Node.js, 28, 47, 69, 110, 134

TypeScript, 45, 47

advantages of, 49

installing, 47

type checking, 41

Visual Studio Code, 29, 48

source.id property, 169

SPAs (single page apps), 9. See also Tip Calculator app

StaleWhileRevalidate strategy, 219, 220221

standalone display mode, 2021

start URL, configuring, 2325, 39

start_url property, 2325, 39

Stencil, 7

stores

adding data to, 107108

creating, 107

deleting data from, 108109

iterating through, 109110

strategies, caching, 9192

cache-only, 9293

network-first, cache-next, 9394

network-first, update-cache, 9498

submitFeedback function, 112, 113114

subOptions object, 148

subscribe method, 148

subscription object, 149, 168

subscription property, 170

subscriptions, notification

expiration of, 162

subscribing to notifications, 148154

doSubscribe function, 151152

postRegistration function, 151152

subscribe method, 148

subscription object, 149

updateUI function, 152153

urlBase64ToUint8Array function, 149

unsubscribing from notifications, 154156

sw.js files. See service workers

sync, background. See background sync

sync databases

choosing, 105

creating, 105106

stores

adding data to, 107108

creating, 107

deleting data from, 108109

iterating through, 109110

sync events. See also background sync

registering, 102103

triggering, 102

sync SDKs, 103

T

tag property, 145

tags, background sync and, 102103

target attribute (<a> tag), 25

tasks, background, 3

testing

background sync, 118119

remote notifications, 156157

test environments, 35

Tip Calculator app, 29, 35

text, returning on error, 8791

theDB object, 106

theme color, configuring, 25

theme_color property, 25

Tip Calculator app

assessment with Lighthouse

Chrome Lighthouse tools, 187189

coding preparation, 182

Lighthouse node module, 189190

Lighthouse plug-in, 182187

automation with PWABuilder

deployable apps, creating, 195196

overview of, 190191

PWABuilder CLI, 197

PWABuilder UI, 191195

Visual Studio PWABuilder extension, 198202

display modes, 19

browser, 2223

fullscreen, 1920

minimal-ui, 2122

standalone, 2021

index.html file, 3133, 3536

Install button, creating

appinstalled event listener, 39

beforeinstallprompt event listener, 36

deferredPrompt object, 36

doInstall function, 37

installbutton variable, 3641

online resources, 10

preventDefault function, 36

start URL, 39

main.js file, 36, 37, 3941

manifest file, 17

precaching service workers

adding precaching to existing service workers, 215218

cache strategies, controlling, 218224

generating, 208214

overview of, 207208

removing, 3738

running, 3335

service worker registration, 3033

testing, 29, 35

web app manifest file, adding, 33

workbox-config.js file, 210, 213, 216217

TLS (Transport Layer Security), HTTP over, 4

transaction object, 108

Transport Layer Security (TLS), HTTP over, 4

triggering sync events, 102

troubleshooting web app manifest files, 4142

Trusted Web Activity (TWA), 7, 196

.ts files, compiling into .js files, 49, 69, 110, 136

tsc. See TypeScript

tsc command, 49, 51, 69, 110, 166

@ts-check, 41

TWA (Trusted Web Activity), 7, 196

two-way communication with MessageChannel, 171179

actionsContainer div, 176

browser long action results, 179

doLongAction function, 176177

doPlayback function, 173

message channels, creating, 171172

message event listener, 172, 173175, 177179

type checking, 41

TypeScript, 45

advantages of, 49

installing, 47

type checking, 41

U

UIs (user interfaces), PWABuilder, 191195

Add Features pane, 193

home page, 191192

Manifest Editor page, 193194

scan results, 192

Service Worker page, 194195

unsubscribe method, 154

unsubscribing from notifications, 154156

update method, 64

updateUI function, 152153, 170

updating service workers, 6466

urlBase64ToUint8Array function, 149

urlList array, 7071

userVisibleOnly, 148149

utils.js file, 77

V

validating notification support, 138

VAPID (Voluntary Application Server Identification), 134137, 166

VAPID_PUBLIC property, 148149

version numbers, service worker, 78

vibrate property, 145

Visual Studio

PWABuilder extension, 198202

command palette, 198199

generated manifest files, 200201

installing, 198

Manifest Generator page, 199200

Visual Studio Code, 29, 48. See also TypeScript

Voluntary Application Server Identification (VAPID), 134137, 166

W-X-Y-Z

W3C (World Wide Web Consortium), 16

waitUntil function, 71, 120, 121

web app manifest files

app icons, 1819

app name, 18

browser support for, 16

display mode configuration, 1923

browser, 2223

fullscreen, 1920

minimal-ui, 2122

standalone, 2021

example of, 17

linking to apps, 17, 3133

overview of, 910

structure of, 1718

Tip Calculator app example

display modes, 1923

index.html file, 3133, 3536

Install button, creating, 3641

main.js file, 3941

manifest file, adding, 33

manifest file code listing, 17

online resources, 10

running, 3335

service worker registration, 3033

start URL, 39

testing, 29, 35

tools for, 42

troubleshooting, 4142

Web App Manifest specification, 16

Web App Manifest Generator, 42

Web App Manifest specification, 16

web app windows, sending data to, 169171

web-push module, 162164

WebSockets, 132

What Is a Progressive Web App?(Keith), 2

Windows computers, notifications on, 129. See also remote notifications

wizards, Workbox Wizard, 208210, 215216

Workbox

components of, 207

installing, 208

NodeJS module, 214

overview of, 207208

precaching service workers

adding precaching to existing service workers, 215218

cache strategies, controlling, 218224

generating, 208214

Webpack plugin, 214

Workbox Wizard, 208210, 215216

workbox injectManifest command, 217

workbox wizard command, 208

workbox wizard -injectManifest command, 215

workbox-config.js file, 210, 213, 216217

World Wide Web Consortium (W3C), 16

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.184.237