SlideShare a Scribd company logo
Cross Platform
Progressive Web
Apps
Simon MacDonald
@macdonst
What is a Progressive
Web App?
“ Progressive Web Apps use modern web
capabilities to deliver an app-like user
experience.
“ They evolve from pages in browser tabs
to immersive, top-level apps, maintaining
the web's low friction at every moment.
“ So they're
just web
pages?
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Progressive
Works for every user,
regardless of browser
choice because it's built
with progressive
enhancement as a core
tenet.
Responsive
Fits any form factor:
desktop, mobile, tablet, or
whatever is next.
Connectivity
Independent
Enhanced with service
workers to work offline or
on low-quality networks.
© Google
App Like
Feels like an app, because
the app shell model
separates the application
functionality from
application content.
Content
Safe
Served via HTTPS to
prevent snooping and to
ensure content hasn't been
tampered with
NOT!
Re-engagable
Makes re-engagement easy
through features like push
notifications.
Installable
Allows users to add apps
they find most useful to
their home screen without
the hassle of an app store.
Linkable
Easily share the application
via URL, does not require
complex installation.
Discoverable
Is identifiable as an
"application" thanks to W3C
manifest and service
worker registration scope,
allowing search engines to
find it.
// index.html
<link rel="manifest" href="/manifest.json">
// manifest.json
{
"short_name": "AirHorner",
"name": "Kinlan's AirHorner of Infamy",
"icons": [
{
"src": "launcher-icon-1x.png",
"type": "image/png",
"sizes": "48x48"
},
{
"src": "launcher-icon-2x.png",
"type": "image/png",
"sizes": "96x96"
},
{
"src": "launcher-icon-4x.png",
"type": "image/png",
"sizes": "192x192"
}
],
"start_url": "index.html?launcher=true"
}
It all starts with
<link rel="manifest" href="manifest.json">
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html?start=a2hs",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
App Shell Architecture
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Service Workers
“ A service worker is a script
that your browser runs in the
background, separate from a
web page
Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/service-worker.js');
});
}
Installation
var CACHE_VERSION = 'v1';
var CACHE_LIST = ['index.html', 'css/main.css', 'js/main.js'];
self.addEventListener('install', function(event) {
event.waitUntil(caches.open(CACHE_VERSION)
.then(function(cache) {
return cache.addAll(CACHE_LIST);
}));
});
Activation
self.addEventListener('activate', function(event) {
console.log("service worker has been activated.");
});
Fetch
self.addEventListener('fetch', function(event) {
console.log('Handling fetch event for ' + event.request.url);
event.respondWith(
caches.match(event.request).then(function(response) {
if (response) {
console.log('Found response in cache:', response);
return response;
}
console.log('No response found in cache. Fetch from network...');
return fetch(event.request);
})
);
});
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
index.html
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
<meta
name="apple-mobile-web-app-title"
content="PWA Test">
index.html
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
<meta
name="apple-mobile-web-app-capable"
content="yes">
index.html
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
<meta name=
"apple-mobile-web-app-status-bar-style"
content="black">
index.html
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
<link
rel="apple-touch-icon"
href="img/icons/apple-touch-icon.png">
index.html
"short_name": "PWA Test",
"name": "PWA Test",
"start_url": "index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#2196F3",
"description": "A sample PWA.",
"icons": [
{
"src": "img/logo-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/logo-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
manifest.json
<link
rel="apple-touch-startup-image"
href="img/Default-Portrait.png">
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
phonegap-plugin-pwa
phonegap-plugin-
service-worker
cordova plugin add https://github.com/phonegap/phonegap-plugin-service-worker
<preference name="ServiceWorker" value="service-worker.js" />
<preference name="CacheCordovaAssets" value="false" />
cordova create myApp --template=<PATH TO ASSETS>
Create an App from your assets
Add the Service Worker plugin
Modify config.xml
cordova run ios
Run your app
npm install -g cordova
Install the Cordova CLI
You're Awesome
The End
Recommended Reading
(article)
(book)
(video)
(article)
Hey, Hey, Cloud Four is a PWA!
Responsive Web Design
Web Push Notifications
Don’t use iOS meta tags irresponsibly in your
Progressive Web Apps

More Related Content

PDF
Angular vs React for Web Application Development
PDF
Progressive Web Apps
PDF
Thinking in Components
PDF
Chrome enchanted 2015
KEY
An Introduction to webOS
PPTX
Building single page applications
PPTX
Disrupting the application eco system with progressive web applications
PPTX
Single Page WebApp Architecture
Angular vs React for Web Application Development
Progressive Web Apps
Thinking in Components
Chrome enchanted 2015
An Introduction to webOS
Building single page applications
Disrupting the application eco system with progressive web applications
Single Page WebApp Architecture

What's hot (20)

PDF
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
PDF
Web Components & Polymer 1.0 (Webinale Berlin)
PDF
The web - What it has, what it lacks and where it must go - Istanbul
PPTX
Enough with the JavaScript already!
PPTX
JavaScript front end performance optimizations
PDF
Booting up with polymer
PDF
Progressive Enhancement 2.0 (Conference Agnostic)
PDF
Booting up with polymer
PDF
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
PDF
Building a Secure App with Google Polymer and Java / Spring
PDF
The Art of AngularJS in 2015
PDF
HTML5 and the dawn of rich mobile web applications
PDF
Usability in the GeoWeb
PDF
Our application got popular and now it breaks
PPTX
Develop a vanilla.js spa you and your customers will love
PDF
AEM responsive
PPTX
Browser Wars Episode 1: The Phantom Menace
PDF
AtlasCamp 2015: Using add-ons to build add-ons
PDF
Web Development for UX Designers
PPTX
Enough with the javas cript already! de Nicholas Zakas
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
Web Components & Polymer 1.0 (Webinale Berlin)
The web - What it has, what it lacks and where it must go - Istanbul
Enough with the JavaScript already!
JavaScript front end performance optimizations
Booting up with polymer
Progressive Enhancement 2.0 (Conference Agnostic)
Booting up with polymer
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Building a Secure App with Google Polymer and Java / Spring
The Art of AngularJS in 2015
HTML5 and the dawn of rich mobile web applications
Usability in the GeoWeb
Our application got popular and now it breaks
Develop a vanilla.js spa you and your customers will love
AEM responsive
Browser Wars Episode 1: The Phantom Menace
AtlasCamp 2015: Using add-ons to build add-ons
Web Development for UX Designers
Enough with the javas cript already! de Nicholas Zakas
Ad

Similar to Building Progressive Web Apps for Android and iOS (20)

PPTX
Building Progressive Web Apps for Windows devices
PPTX
Progressive Web Apps - Intro & Learnings
PDF
Progressive Web Apps
PDF
Bruce Lawson: Progressive Web Apps: the future of Apps
PPTX
Cloud Endpoints _Polymer_ Material design by Martin Görner
PPTX
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
PDF
Web APIs & Apps - Mozilla
PPTX
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
PDF
Atomic Design con Pattern Lab
PDF
Always on! Or not?
PDF
Progressive Web Apps - NPD Meet
PDF
Service workers
PDF
Pivorak.javascript.global domination
PDF
Andriy Vandakurov about "Frontend. Global domination"
PDF
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
PDF
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
PDF
Make your PWA feel more like an app
PDF
Pinkoi Mobile Web
PDF
Micro app-framework
PDF
Micro app-framework - NodeLive Boston
Building Progressive Web Apps for Windows devices
Progressive Web Apps - Intro & Learnings
Progressive Web Apps
Bruce Lawson: Progressive Web Apps: the future of Apps
Cloud Endpoints _Polymer_ Material design by Martin Görner
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
Web APIs & Apps - Mozilla
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
Atomic Design con Pattern Lab
Always on! Or not?
Progressive Web Apps - NPD Meet
Service workers
Pivorak.javascript.global domination
Andriy Vandakurov about "Frontend. Global domination"
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
[Serverless Meetup Tokyo #3] Serverless in Azure (Azure Functionsのアップデート、事例、デ...
Make your PWA feel more like an app
Pinkoi Mobile Web
Micro app-framework
Micro app-framework - NodeLive Boston
Ad

More from FITC (20)

PPTX
Cut it up
PDF
Designing for Digital Health
PDF
Profiling JavaScript Performance
PPTX
Surviving Your Tech Stack
PDF
How to Pitch Your First AR Project
PDF
Start by Understanding the Problem, Not by Delivering the Answer
PDF
Cocaine to Carrots: The Art of Telling Someone Else’s Story
PDF
Everyday Innovation
PDF
HyperLight Websites
PDF
Everything is Terrifying
PDF
Post-Earth Visions: Designing for Space and the Future Human
PDF
The Rise of the Creative Social Influencer (and How to Become One)
PDF
East of the Rockies: Developing an AR Game
PDF
Creating a Proactive Healthcare System
PDF
World Transformation: The Secret Agenda of Product Design
PDF
The Power of Now
PDF
High Performance PWAs
PDF
Rise of the JAMstack
PDF
From Closed to Open: A Journey of Self Discovery
PDF
Projects Ain’t Nobody Got Time For
Cut it up
Designing for Digital Health
Profiling JavaScript Performance
Surviving Your Tech Stack
How to Pitch Your First AR Project
Start by Understanding the Problem, Not by Delivering the Answer
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Everyday Innovation
HyperLight Websites
Everything is Terrifying
Post-Earth Visions: Designing for Space and the Future Human
The Rise of the Creative Social Influencer (and How to Become One)
East of the Rockies: Developing an AR Game
Creating a Proactive Healthcare System
World Transformation: The Secret Agenda of Product Design
The Power of Now
High Performance PWAs
Rise of the JAMstack
From Closed to Open: A Journey of Self Discovery
Projects Ain’t Nobody Got Time For

Recently uploaded (20)

PPTX
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
REPORT: Heating appliances market in Poland 2024
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
REPORT: Heating appliances market in Poland 2024
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
NewMind AI Weekly Chronicles - August'25 Week I
Sensors and Actuators in IoT Systems using pdf
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Transforming Manufacturing operations through Intelligent Integrations
KodekX | Application Modernization Development
NewMind AI Monthly Chronicles - July 2025
A Day in the Life of Location Data - Turning Where into How.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CroxyProxy Instagram Access id login.pptx
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?

Building Progressive Web Apps for Android and iOS

  • 3. What is a Progressive Web App?
  • 4. “ Progressive Web Apps use modern web capabilities to deliver an app-like user experience. “ They evolve from pages in browser tabs to immersive, top-level apps, maintaining the web's low friction at every moment.
  • 5. “ So they're just web pages?
  • 8. Progressive Works for every user, regardless of browser choice because it's built with progressive enhancement as a core tenet.
  • 9. Responsive Fits any form factor: desktop, mobile, tablet, or whatever is next.
  • 10. Connectivity Independent Enhanced with service workers to work offline or on low-quality networks. © Google
  • 11. App Like Feels like an app, because the app shell model separates the application functionality from application content. Content
  • 12. Safe Served via HTTPS to prevent snooping and to ensure content hasn't been tampered with NOT!
  • 13. Re-engagable Makes re-engagement easy through features like push notifications.
  • 14. Installable Allows users to add apps they find most useful to their home screen without the hassle of an app store.
  • 15. Linkable Easily share the application via URL, does not require complex installation.
  • 16. Discoverable Is identifiable as an "application" thanks to W3C manifest and service worker registration scope, allowing search engines to find it. // index.html <link rel="manifest" href="/manifest.json"> // manifest.json { "short_name": "AirHorner", "name": "Kinlan's AirHorner of Infamy", "icons": [ { "src": "launcher-icon-1x.png", "type": "image/png", "sizes": "48x48" }, { "src": "launcher-icon-2x.png", "type": "image/png", "sizes": "96x96" }, { "src": "launcher-icon-4x.png", "type": "image/png", "sizes": "192x192" } ], "start_url": "index.html?launcher=true" }
  • 17. It all starts with <link rel="manifest" href="manifest.json">
  • 18. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 19. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 20. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 21. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html?start=a2hs", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ]
  • 22. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 23. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 24. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 25. "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json
  • 30. Service Workers “ A service worker is a script that your browser runs in the background, separate from a web page
  • 31. Registration if ('serviceWorker' in navigator) { window.addEventListener('load', function() { navigator.serviceWorker.register('/service-worker.js'); }); }
  • 32. Installation var CACHE_VERSION = 'v1'; var CACHE_LIST = ['index.html', 'css/main.css', 'js/main.js']; self.addEventListener('install', function(event) { event.waitUntil(caches.open(CACHE_VERSION) .then(function(cache) { return cache.addAll(CACHE_LIST); })); });
  • 34. Fetch self.addEventListener('fetch', function(event) { console.log('Handling fetch event for ' + event.request.url); event.respondWith( caches.match(event.request).then(function(response) { if (response) { console.log('Found response in cache:', response); return response; } console.log('No response found in cache. Fetch from network...'); return fetch(event.request); }) ); });
  • 39. index.html "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json <meta name="apple-mobile-web-app-title" content="PWA Test">
  • 40. index.html "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json <meta name="apple-mobile-web-app-capable" content="yes">
  • 41. index.html "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json <meta name= "apple-mobile-web-app-status-bar-style" content="black">
  • 42. index.html "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json <link rel="apple-touch-icon" href="img/icons/apple-touch-icon.png">
  • 43. index.html "short_name": "PWA Test", "name": "PWA Test", "start_url": "index.html", "display": "standalone", "background_color": "#fff", "theme_color": "#2196F3", "description": "A sample PWA.", "icons": [ { "src": "img/logo-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "img/logo-512.png", "sizes": "512x512", "type": "image/png" } ] manifest.json <link rel="apple-touch-startup-image" href="img/Default-Portrait.png">
  • 49. cordova plugin add https://github.com/phonegap/phonegap-plugin-service-worker <preference name="ServiceWorker" value="service-worker.js" /> <preference name="CacheCordovaAssets" value="false" /> cordova create myApp --template=<PATH TO ASSETS> Create an App from your assets Add the Service Worker plugin Modify config.xml cordova run ios Run your app npm install -g cordova Install the Cordova CLI
  • 52. Recommended Reading (article) (book) (video) (article) Hey, Hey, Cloud Four is a PWA! Responsive Web Design Web Push Notifications Don’t use iOS meta tags irresponsibly in your Progressive Web Apps