in 2015[1] • Appear to the user like a native app • They can work offline, but don’t have to • Operating system agnostic (Windows, Android, iOS or OSX) [1] https://infrequently.org/2015/06/progressive-apps-escaping-tabs-without-losing-our-soul/ @MPOram
right? A Service Worker* A bit like a client side proxy Web App Manifest Your Apps settings *not in Firefox User permission To install your app and use the APIs @MPOram
Listen for the beforeinstallprompt Event • Event fires if install criteria are met • Display install prompt after event has fired • Acceptance of the prompt results in automatic install of your application (Adds it to their home screen) @MPOram
Runs in a separate execution thread • No DOM access (use the postMessage API to communicate with client) • Can interact with all network requests • Most commonly used for Cache management @MPOram
(reqDate < reqDate-300000) { // 5 minutes ago return fetch(event.request); } else { // return previous request from cache } ) }) Only call the API every 5 minutes @MPOram
displays User interaction User refreshes or performs an action that requires the same data Service Worker Service Worker picks up fetch and decides how to respond Response Data comes back from service worker Update UI Update DOM with response data @MPOram
caching static files, works with data such as JSON localStorage Similar to the service worker cache but is synchronous so does not work inside a service worker IndexedDB Works asynchronously so can be used inside a service worker for data storage @MPOram
'toDoList'],"readwrite") .objectStore('toDoList') IDB.add({name: "Mike"}, 1) // store JSON with key of 1 // retrieve data stored in key 1 var data = IDB.get(1) data.name = 'Charlie' IDB.put(data, 1) // update JSON at key of 1 @MPOram
stored in IndexedDB and displayed User action User performs a page action Service Worker Performs fetch request or falls back to IndexedDB if network down Update UI Update DOM with response data @MPOram
service-worker.js self.addEventListener('sync', function (event) { if (event.tag === 'update-trains') { // fetch new train data when online event.waitUntil(updateTrains()) } }) Offline Support - background sync @MPOram
app’s files if the app is unused for a few weeks. The icon will still be there on the home screen, when accessed the app will be downloaded again. https://medium.com/@firt/progressive-web-apps-on-ios-are-here-d00430dee3a7 @MPOram
such as Bluetooth, Touch ID, Face ID, altimeter sensor, app payments or contact info. No Push Notifications or Siri integration on iOS. https://medium.com/@firt/progressive-web-apps-on-ios-are-here-d00430dee3a7 @MPOram