Manifest and service work

{
“name”: “Docomo Wallet Explorer”,
“short_name”: “WalletExplorer”,
“start_url”: “index.html”,
“display”: “standalone”,
“background_color”: “#ffffff”,
“theme_color”: “#d0eaff”,
“orientation”: “portrait”,
“icons”: [
{
“src”: “icon-192.png”,
“sizes”: “192×192”,
“type”: “image/png”
},
{
“src”: “icon-512.png”,
“sizes”: “512×512”,
“type”: “image/png”
}
]
}

Service worker

const CACHE_NAME = ‘wallet-explorer-v1’;
const urlsToCache = [
‘index.html’,
‘manifest.json’,
‘icon-192.png’,
‘icon-512.png’
];

// Install: cache core files
self.addEventListener(‘install’, event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => cache.addAll(urlsToCache))
);
});

// Activate: clean up old caches
self.addEventListener(‘activate’, event => {
event.waitUntil(
caches.keys().then(keys => Promise.all(
keys.map(key => key !== CACHE_NAME && caches.delete(key)) ))
);
});

// Fetch: serve cached assets
self.addEventListener(‘fetch’, event => {
event.respondWith(
caches.match(event.request)
.then(response => response || fetch(event.request))
);
});

Sw.JS

const CACHE_NAME = “phase14-cache-v1”;
const URLS_TO_CACHE = [
“/”,
“/index.html”,
“/manifest.json”,
“/service-worker.js”,
“/icon-192.png”,
“/icon-512.png”
];

self.addEventListener(“install”, event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => {
return cache.addAll(URLS_TO_CACHE);
})
);
});

self.addEventListener(“fetch”, event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});

self.addEventListener(“activate”, event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cache => {
if (cache !== CACHE_NAME) {
return caches.delete(cache);
}
})
);
})
);
});

Manifest.json

{
“name”: “Phase 14 Governance PWA”,
“short_name”: “Phase14”,
“start_url”: “./index.html”,
“display”: “standalone”,
“background_color”: “#0f0f0f”,
“theme_color”: “#0f0f0f”,
“icons”: [
{
“src”: “icon-192.png”,
“sizes”: “192×192”,
“type”: “image/png”
},
{
“src”: “icon-512.png”,
“sizes”: “512×512”,
“type”: “image/png”
}
]
}