@mittlmedien
info@mittl-medien.de
Benefit from the advantages of a Progressive Web App 🤗
Web - Server
Service Worker
Cache
Cache API
Clear advantage, one app of all operating system.
navigator.serviceWorker.register("serviceworker.js")
.then( (registration) => {
setInterval( () => registration.update(), 86400 );
});
Static files
Network first
Offline first
Network speed
if (navigator.connection.downlinkMax > 50) { // fast Network
}
if (navigator.storage && navigator.storage.persist)
navigator.storage.persist().then(function(persistent) {
if (persistent)
console.log("Storage will not be cleared except by explicit user action");
else
console.log("Storage may be cleared by the UA under storage pressure.");
});
Data exchange via background sync with fallback (online / offline)
🚫localStorage🚫
States are:
Foreground
Background
Send own Push Messages through VapidMethod
(Voluntary Application Server Identification)
(Web Share Target API)
if (navigator.share) {
navigator.share({
title: document.title,
text: 'Hello JAB 2020',
url: 'https://jandbeyond.org/',
});
})
.then(() => {
// do something on success
})
.catch(err => {
// do something on error
});
}
App is loading
App is going in background {visibilitychange}
App is closed {freeze}
App is called again {resume}
{visibilitychange)
The event could be triggered.
12.x 😟
13.x 🙂
<link rel="manifest" href="/manifest.json">
{
"lang": "de",
"name": "Joomla",
"short_name": "Joomla",
"description": "Meine WordPress PWA",
"theme_color": "#99ccff",
"background_color": "#99ccff",
"display": "standalone",
"Scope": "/",
"start_url": "/",
"icons": [
{
"src": "images/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
new Maskable Icon
installButton.addEventListener('click', e => {
installPrompt.prompt()
})
let installPrompt
window.addEventListener('beforeinstallprompt', e => {
e.preventDefault()
installPrompt = e;
})
for iOs, you could create a layer, with a notice message for installation
{
"name": "PlayerFM",
"start_url": "https://app.playerfm.com",
…
"shortcuts": [
{
"name": "Play Later",
"description": "View the list of podcasts you saved for later",
"url": "/play-later",
"icons": [
{
"src": "/icons/play-later.svg",
"type": "image/svg+xml",
"purpose": "any"
}
]
},
{
"name": "Subscriptions",
"description": "View the list of podcasts you listen to",
"url": "/subscriptions",
Simple registration with Google, Facebook or iCloud Account (OAuth, Auth0)
Simple payment with once deposited information
(Apple Pay, Google Pay)
Communication between client and Service Worker
self.addEventListener('message', messageEvent => {
if (messageEvent.data === 'clean up caches') {
trimCacheAsync(imageCacheName, 50)
trimCacheAsync(pagesCacheName, 30)
}
})
navigator.serviceWorker.controller.postMessage('clean up caches')
Registration
Service Worker
Communication between Service Worker and client
const respondTo = async ({ req, clientId }) => {
const client = await self.clients.get(clientId);
client.postMessage("Hello JAB 2020, it's amazing");
}
return caches.match(req);
};
navigator.serviceWorker.addEventListener("message", (evt) => {
window.alert(evt.data);
});
Browser / App
Serviceworker
based on the Web API
Apple Configurator 2
App Launcher Android - PWA Certified Url
TWA (Trusted Web Activity) Google Play Store
Companies offer a Native App and a PWA at the same time:
Shopsystem:
Reasons are:
or your Website with a simple Service Worker for caching or more features?
Google Workbox
Google PWA Training:
https://developers.google.com/web/ilt/pwa/
Maximiliano Firtman @firt
Books 📚:
Jeremy Keith. “Going Offline”
Dean Alan Hume "Progressive Web Apps"
Tal Ater "Building Progressive Web Apps"
📬 info@mittl-medien.de
Twitter: @mittlmedien