GDG DevFest Tokyo 2018
Takanori Oki
A design philosophy that centers around providing a baseline of essential content and functionality to as many users as possible, while at the same time going further and delivering the best possible experience only to users of the most modern browsers that can run all the required code.
App
Old Browser
Latest Browser
Minimum
functions
Maximum
functions
For example, the Payment Request API
Installable,
Push notification,
Immersive full screen experience
PWA
Service Workers
Offline
Support
Push
Notification
Add Icon to
Home Screen
background
sync
Web App Manifest
Add to Home Screen | ||||
Service Workers | ||||
Push Notifications | ||||
Credential manegement API | ||||
Payment Request API |
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('service-worker.js', {
scope: '/',
});
});
}
You write this code into
index.html or any External JavaScript File
module.exports = {
staticFileGlobs: [
'manifest.json',
'src/**/*',
],
runtimeCaching: [
{
urlPattern: /\/@webcomponents\/webcomponentsjs\//,
handler: 'fastest'
},
{
urlPattern: /^https:\/\/fonts.gstatic.com\//,
handler: 'fastest'
}
]
};
<link rel="manifest" href="/manifest.json">
{
"name": "My App",
"short_name": "My App",
"description": "My App description",
"start_url": "/",
"display": "standalone",
"theme_color": "#3f51b5",
"background_color": "#3f51b5",
"icons": [
{
"src": "images/manifest/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/manifest/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
Completed !
PWA
LitElement
Redux
PRPL
pwa-helpers
https://github.com/Polymer/pwa-helpers
Small helper methods or mixins to help build a PWA
This contains Basic helpers, Test helpers and
Redux helpers
network.js
Calls a callback whenever the network connectivity of the app changes.
import { installOfflineWatcher }
from '../node_modules/pwa-helpers/network.js';
installOfflineWatcher((offline) => {
console.log(offline ? ' offline' : 'online');
});
import { installMediaQueryWatcher }
from '../node_modules/pwa-helpers/media-query.js';
installMediaQueryWatcher(`(min-width: 600px)`, (matches) => {
console.log(matches ? 'wide screen' : 'narrow sreen');
});
Calls a callback whenever a media-query matches in response to the viewport size changing.
Web Fundamentals
Native Apps
PWA
Push Notification
DO NOT
DEMAND PERMISSIONS FOR NOTIFICATION
ON PAGE LOAD
If blocked,
Apps can't request permission again.
We should think
the
story that user allow push notifications.
Safari
iOS Safari can't share credentials between PWA and Browser.
So, sometimes, Users can't login...
Design
PWA need to be designed as
native apps.
Don't use
Full-screen view
without thinking!!
Let's make PWA and add FIRE experiences
Thank you!