diff --git a/web_install/144x144.png b/web_install/144x144.png new file mode 100644 index 0000000..32e0955 Binary files /dev/null and b/web_install/144x144.png differ diff --git a/web_install/48x48.png b/web_install/48x48.png new file mode 100644 index 0000000..aa7d868 Binary files /dev/null and b/web_install/48x48.png differ diff --git a/web_install/app.js b/web_install/app.js new file mode 100644 index 0000000..627c902 --- /dev/null +++ b/web_install/app.js @@ -0,0 +1,26 @@ +const registerServiceWorker = async () => { + try { + await navigator.serviceWorker.register("./sw.js"); + console.log("Service worker registered"); + } catch (e) { + console.log(`Registration failed: ${e}`); + } +}; + +if (navigator.serviceWorker) { + registerServiceWorker(); +} + +// Handle install buttons. +const installPreset = (e) => { + // Make sure to update the visible code sample in index.html when updating + // this. + let manifest_id = "https://amandabaker.github.io/pwa/web_install.html"; + let install_url = manifest_id; + navigator.install(manifest_id, install_url); +}; + +// const installCustom = (e) => {} + +document.getElementById("installPreset").addEventListener("click", installPreset); +// document.getElementById("installCustom").addEventListener("click", installCustom); diff --git a/web_install/index.html b/web_install/index.html new file mode 100644 index 0000000..4008dca --- /dev/null +++ b/web_install/index.html @@ -0,0 +1,37 @@ + + +
+ + ++ A debugging tool for the Web Install API. See more info in the + explainer + and to-do's in this + GitHub issue. +
+ +Executes:
+
+ let manifest_id = "https://amandabaker.github.io/pwa/web_install.html";
+ let install_url = manifest_id;
+ navigator.install(manifest_id, install_url);
+
+
+
+
+
+
+
diff --git a/web_install/manifest.webmanifest b/web_install/manifest.webmanifest
new file mode 100644
index 0000000..8689161
--- /dev/null
+++ b/web_install/manifest.webmanifest
@@ -0,0 +1,16 @@
+{
+ "name": "Web Install Sample",
+ "display": "standalone",
+ "start_url": "./index.html",
+ "theme_color": "#296f78",
+ "icons": [
+ {
+ "src": "48x48.png",
+ "sizes": "48x48"
+ },
+ {
+ "src": "144x144.png",
+ "sizes": "144x144"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/web_install/sw.js b/web_install/sw.js
new file mode 100644
index 0000000..fb76383
--- /dev/null
+++ b/web_install/sw.js
@@ -0,0 +1,12 @@
+
+this.addEventListener('install', async (event) => {
+ return;
+});
+
+self.addEventListener('fetch', e => {
+ e.respondWith(
+ fetch(e.request).catch(() => {
+ return new Response('Hello offline page');
+ })
+ );
+});