<!-- Hide Safari UI Components --> | <!-- Hide Safari UI Components --> | ||||
<meta name="apple-mobile-web-app-capable" content="yes" /> | <meta name="apple-mobile-web-app-capable" content="yes" /> | ||||
<!-- iOS Status bar: black or black-translucent --> | <!-- iOS Status bar: black or black-translucent --> | ||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> | |||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | |||||
<!-- iOS App Name next to Icon --> | <!-- iOS App Name next to Icon --> | ||||
<meta name="apple-mobile-web-app-title" content="OHM News"> | <meta name="apple-mobile-web-app-title" content="OHM News"> | ||||
<!-- Icon: No transparency allowed --> | <!-- Icon: No transparency allowed --> | ||||
<link rel="apple-touch-icon" href="img/launcher/launcher_app_icon_192.png"> <!-- iphone --> | |||||
<link rel="apple-touch-icon" sizes="152x152" href="img/launcher/launcher_app_icon_152.png"><!-- ipad --> | |||||
<link rel="apple-touch-icon" sizes="180x180" href="img/launcher/launcher_app_icon_180.png"><!-- iphone-retina --> | |||||
<link rel="apple-touch-icon" sizes="167x167" href="img/launcher/launcher_app_icon_167.png"><!-- ipad-retina --> | |||||
<link rel="apple-touch-icon" href="img/launcher/ios_launcher_app_icon_192.png"> <!-- iphone --> | |||||
<link rel="apple-touch-icon" sizes="152x152" href="img/launcher/ios_launcher_app_icon_152.png"><!-- ipad --> | |||||
<link rel="apple-touch-icon" sizes="180x180" href="img/launcher/ios_launcher_app_icon_180.png"><!-- iphone-retina --> | |||||
<link rel="apple-touch-icon" sizes="167x167" href="img/launcher/ios_launcher_app_icon_167.png"><!-- ipad-retina --> | |||||
<!-- Splash screen: If not set, will be white screen --> | <!-- Splash screen: If not set, will be white screen --> | ||||
<link rel="apple-touch-startup-image" sizes="2048x2732" href="ios-splash/apple_splash_2048.png" /><!-- Tablet --> | <link rel="apple-touch-startup-image" sizes="2048x2732" href="ios-splash/apple_splash_2048.png" /><!-- Tablet --> | ||||
<link rel="apple-touch-startup-image" sizes="1668x2224"href="ios-splash/apple_splash_1668.png" /><!-- Tablet --> | <link rel="apple-touch-startup-image" sizes="1668x2224"href="ios-splash/apple_splash_1668.png" /><!-- Tablet --> |
"name": "OHM News", | "name": "OHM News", | ||||
"icons": [ | "icons": [ | ||||
{ | { | ||||
"src":"img/launcher/launcher_app_icon_192.png", | |||||
"src":"img/launcher/android_launcher_app_icon_192.png", | |||||
"type": "image/png", | "type": "image/png", | ||||
"sizes": "192x192" | "sizes": "192x192" | ||||
}, | }, | ||||
{ | { | ||||
"src":"img/launcher/launcher_app_icon_512.png", | |||||
"src":"img/launcher/android_launcher_app_icon_512.png", | |||||
"type": "image/png", | "type": "image/png", | ||||
"sizes": "512x512" | "sizes": "512x512" | ||||
} | } |
self.addEventListener('fetch', event => { | self.addEventListener('fetch', event => { | ||||
// Provide HTTPS URL for query data. | // Provide HTTPS URL for query data. | ||||
//const postMsgURL = 'https://me.efi.th-nuernberg.de/om/api/createMsg'; | //const postMsgURL = 'https://me.efi.th-nuernberg.de/om/api/createMsg'; | ||||
const postMsgURL = 'http://localhost:8013/api/createMsg'; | |||||
//const postMsgURL = 'http://localhost:8013/api/createMsg'; | |||||
/* We should only cache GET requests, and deal with the rest of method in the | /* We should only cache GET requests, and deal with the rest of method in the | ||||
client-side, by handling failed POST,PUT,PATCH,etc. requests. */ | client-side, by handling failed POST,PUT,PATCH,etc. requests. */ | ||||
const networkPromise = fetch(requestURL); | const networkPromise = fetch(requestURL); | ||||
const cachedResponse = await caches.match(event.request); | const cachedResponse = await caches.match(event.request); | ||||
if (cachedResponse) return cachedResponse; | |||||
const networkResponse = await networkPromise; | const networkResponse = await networkPromise; | ||||
// Check if response is valid, status is 200, response type is basic | // Check if response is valid, status is 200, response type is basic | ||||
// be read once. Placing a response in the cache counts as a read. | // be read once. Placing a response in the cache counts as a read. | ||||
cache.put(event.request, networkResponse.clone()); | cache.put(event.request, networkResponse.clone()); | ||||
if (cachedResponse) return cachedResponse; | |||||
console.log('[ServiceWorker] Fetch', event.request); | console.log('[ServiceWorker] Fetch', event.request); | ||||
return networkResponse; | return networkResponse; | ||||
} catch (err) { | } catch (err) { | ||||
// Report a lack of connectivity to the user. | // Report a lack of connectivity to the user. | ||||
console.log('No Network connection: ',err); | console.log('No Network connection: ',err); | ||||
return cachedResponse; | |||||
} | } | ||||
}()); | }()); | ||||
}); | }); |