1. BUILDING A PWA
F O R E V E R Y O N E W H O I S S C A R E D T O . . .
2. RAYMOND CAMDEN
• Senior Developer Advocate for Auth0 Extend
• Extend, serverless, web and Enterprise Cat demos
• Blogging at raymondcamden.com
• Tweeting at @raymondcamden
10. MANIFEST
• "Web App Manifest"
• Just a JSON file (woot!)
• Allows for "installable" web apps
• Controls behavior when launched
11. MANIFEST
• The name (as it appears in the shortcut)
• Icons (of various sizes)
• Splash screen and colors (bg and toolbar)
• Chrome
• Forced Orientation
• The starting URL (handy for passing a param to note the launch)
– https://(something)/index.html?utm_source=homescreen
15. (AUTO) ADD TO HOME
• AKA Web Install Banners
• *Current* criteria is:
– manifest with short_name, name, 192x192 icon (png only), start_url
– service worker
– https
– "Meets a site engagement heuristic defined by Chrome (this is regularly being changed)."
• Event is fired: beforeinstallprompt
• Details: https://developers.google.com/web/fundamentals/app-install-banners/
19. THANKS IOS
• Doesn't support manifest :(
• But you can configure...
• https://developer.apple.com/library/content/document
ation/AppleApplications/Reference/SafariWebContent
/ConfiguringWebApplications/ConfiguringWebApplica
tions.html
23. SERVICE WORKERS - INTRO
• JavaScript
• A script registered via a script
• Now - forget everything you know about <script>
24. "REGULAR" JS
• You load foo.html
• foo.html is all like <script src="ftw_js_is_awesome_unicorns.js"></script>
• Code executes while the tab (window) is "alive"
• Close the tab and ftw_js_is_awesome_unicorns.js goes bye bye
25. SERVICE WORKER JS
• Runs in parallel to pages in it's scope
• Can't actually do anything the first time it loads
• Can run when you're not even on the page
• Can intercept every single network request (to be clear, not just XHR)
• Can work with the browser cache
• Can fire off notifications while you're away (and you totally won't abuse this)
• Can respond to push notifications (and you totally won't abuse this)
• Can help you sync data
• Can't touch the DOM
26. MORE SERVICE WORKER
• You can (and must) check for support
• Requires https, but localhost is ok
• They have a life cycle
• Devtools will be very, very helpful
29. CACHING!
• CacheStorage API (LINK)
• Keyed by name (this is how you version)
• Ability to add one or multiple URLs
• Ability to read from the cache (and delete)
38. EXCEPT...
• You want to change a file
• You only want to use the cache if offline
• You want some mix of things where you use the cache first then network but then sometimes
you want to hit the network first and then cache and oh yeah maybe you want to use the
cache and that's cool but maybe you want to hit the network in the background and passively
update stuff and oh my god does this end?
39. GOOD NEWS/BAD NEWS
• Good News: Caching Strategies exist
• Bad News: You're responsible for figuring it out
• See "The Offline Cookbook" - https://developers.google.com/web/fundamentals/instant-and-
offline/offline-cookbook/
• See Workbox: https://developers.google.com/web/tools/workbox/
40. EXCEPT ROUND TWO...
• iOS - no support for Service Workers
• But officially "in development" for WebKit
• AppCache
43. BACKGROUND SYNC
• Another ServiceWorker feature
• App js tells SW js - "hey, start syncing Foo"
• SW says - "Ok, no problem. I'll get around to it."
• SW will try to do Foo (you write the logic)
• If it fails, it will try again (and again...)
• Finally, it will try one last time and *tell* you as well
• https://developers.google.com/web/updates/2015/12/background-sync
46. PUSH NOTIFICATIONS
• Two APIs - Push and Notification
• Notification - https://developer.mozilla.org/en-US/docs/Web/API/notification
• Request permission to show a notification
• You can show it
50. PUSH
• User subscribes to push messaging (two step process)
• Your server sends a message to central Message server
• Messaging server talks to Service Worker
• Service Worker does whatever (probably Notification)
61. SAFARI AND PWAS
• Supported in the *released* iOS
• Only in Safari, no other browser
• Service Workers (Caching) and App Manifests (not entirely)
• No Push or Sync
• And it gets better: https://medium.com/@firt/pwas-are-coming-to-ios-11-3-cupertino-we-have-
a-problem-2ff49fd7d6ea
62. ANY QUESTIONS?
• Email me at raymondcamden@gmail.com
• Visit my awesome blog at raymondcamden.com
• Follow my awesome Twitter account at @raymondcamden