{ "name": "Kinlan's Amazing Application ++", "short_name": "Kinlan's Amaze App", "icons": [ { "src": "launcher-icon-3x.png", "sizes": "144x144", "type": "image/png" } ], "start_url": "index.html", "display": "standalone" }
<link rel="manifest" href="/manifest.json">
link[rel="manifest"]
name
short_name
icons
start_url
display
standalone
meta[name="theme-color"]
content
<meta name="theme-color" content="#db5945">
fetch
navigator.serviceWorker.register('/sw.js') .then(function(registration) { // Success! }).catch(function(error) { // Error... });
self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(response) { return response || fetch(event.request); }) ); });
navigator.serviceWorker.ready().then(function(sw) { sw.pushManager.subscribe().then(function(sub) { // After permission is granted sub.subscriptionId; // registration Id sub.endpoint; // GCM URL }); });
self.addEventListener('push', function(event) { event.waitUntil( self.registration.showNotification(title, { body: body, icon: icon, tag: tag } }); });