-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b6b9d
commit 9078ba3
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<!-- Responsive --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" | ||
content="width=device-width, | ||
initial-scale=1"> | ||
<meta http-equiv="X-UA-Compatible" | ||
content="ie=edge"> | ||
|
||
<!-- Title --> | ||
<title>PWA Tutorial</title> | ||
|
||
<!-- Meta Tags required for | ||
Progressive Web App --> | ||
<meta name= | ||
"apple-mobile-web-app-status-bar" | ||
content="#aa7700"> | ||
<meta name="theme-color" | ||
content="black"> | ||
|
||
<!-- Manifest File link --> | ||
<link rel="manifest" | ||
href="pwatest.manifest.json"> | ||
</head> | ||
|
||
<body> | ||
<h1>PWA Test</h1> | ||
|
||
|
||
<p> | ||
Progressive Web Apps can be installed as an app. This page is one. | ||
</p> | ||
|
||
|
||
<script> | ||
window.addEventListener('load', () => { | ||
registerSW(); | ||
}); | ||
|
||
// Register the Service Worker | ||
async function registerSW() { | ||
if ('serviceWorker' in navigator) { | ||
try { | ||
await navigator | ||
.serviceWorker | ||
.register('pwatest.service.js'); | ||
} | ||
catch (e) { | ||
window.alert('Failed To Register Service Worker: ' + e); | ||
} | ||
} | ||
else { | ||
window.alert("Service Workers Not Supported In Browser"); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name":"PWA Test", | ||
"short_name":"PWA", | ||
"start_url":"pwatest.html", | ||
"display":"standalone", | ||
"background_color":"#5900b3", | ||
"theme_color":"black", | ||
"scope": ".", | ||
"description":"Tests out PWAs.", | ||
"icons":[ | ||
{ | ||
"src":"turtle.png", | ||
"sizes":"250x250", | ||
"type":"image/png" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var staticCacheName = "pwa"; | ||
|
||
self.addEventListener("install", function (e) { | ||
e.waitUntil( | ||
caches.open(staticCacheName).then(function (cache) { | ||
return cache.addAll(["/", "/pwatest.html"]); | ||
}) | ||
); | ||
}); | ||
|
||
self.addEventListener("fetch", function (event) { | ||
console.log(event.request.url); | ||
|
||
event.respondWith( | ||
caches.match(event.request).then(function (response) { | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.