diff --git a/app-icon.png b/app-icon.png deleted file mode 100644 index eecd10c..0000000 Binary files a/app-icon.png and /dev/null differ diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index 177b437..0000000 Binary files a/favicon.ico and /dev/null differ diff --git a/icon-192x192.png b/icon-192x192.png new file mode 100644 index 0000000..5583bd0 Binary files /dev/null and b/icon-192x192.png differ diff --git a/icon-512x512.png b/icon-512x512.png new file mode 100644 index 0000000..2ba1f9c Binary files /dev/null and b/icon-512x512.png differ diff --git a/index.html b/index.html index f5caa2f..071c723 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,9 @@ permission.site - - + + + @@ -32,6 +33,7 @@ + @@ -98,7 +100,7 @@ Async Clipboard - These buttons test the new Async Clipboard API. + These buttons test the new Async Clipboard API.
Note that these tests are different from the "Copy" button on this page, which uses the old (synchronous) execCommand method to write to the clipboard. @@ -123,6 +125,15 @@ May succeed without permission request depending on the implementation. + + Notifications + + On iOS and iPadOS, to request notification permission, web apps must first be added to the Home Screen. +
+ In Meta Quest Browser, to request notification permission, web apps must be + packaged. + + diff --git a/index.js b/index.js index ed5c635..cc3234f 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,16 @@ // - Indicate if permissions are already granted, if the relevant API allows it. window.addEventListener("load", function() { + var deferredInstallEvent; + + window.addEventListener("beforeinstallprompt", (event) => { + event.preventDefault(); + deferredInstallEvent = event; + }); + + window.addEventListener("appinstalled", (event) => { + displayOutcome("install", "success")(); + }); var toggle = document.querySelector("#toggle"); toggle.classList.add("instant"); @@ -93,6 +103,26 @@ window.addEventListener("load", function() { ); var register = { + "install": function() { + if ("BeforeInstallPromptEvent" in window) { + if (deferredInstallEvent) { + deferredInstallEvent.prompt(); + deferredInstallEvent.userChoice + .then((choiceResult) => { + if (choiceResult.outcome === "accepted") { + displayOutcome("install", "success")(); + } + // If install prompt is dismissed, closed or ignored, it can be requested again. + }) + .catch((error) => { + displayOutcome("install", "error")(error); + }); + deferredInstallEvent = null; + } + } else { + displayOutcome("install", "error")("Install is not supported"); + } + }, "notifications": function () { Notification.requestPermission( displayOutcomeForNotifications diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..dcd1aa1 --- /dev/null +++ b/manifest.json @@ -0,0 +1,81 @@ +{ + "name": "permission.site", + "short_name": "permission.site", + "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + "start_url": "./?utm_source=web_app_manifest", + "scope": "./", + "display": "standalone", + "theme_color": "#eeeeee", + "background_color": "#eeeeee", + "icons": [ + { + "src": "./icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + "screenshots": [ + { + "src": "./screenshot-1.png", + "type": "image/png", + "sizes": "1080x1920", + "form_factor": "narrow" + }, + { + "src": "./screenshot-2.png", + "type": "image/png", + "sizes": "1080x1920", + "form_factor": "narrow" + }, + { + "src": "./screenshot-3.png", + "type": "image/png", + "sizes": "1080x1920", + "form_factor": "narrow" + }, + { + "src": "./screenshot-4.png", + "type": "image/png", + "sizes": "1920x1080", + "form_factor": "wide" + }, + { + "src": "./screenshot-5.png", + "type": "image/png", + "sizes": "1920x1080", + "form_factor": "wide" + }, + { + "src": "./screenshot-6.png", + "type": "image/png", + "sizes": "1920x1080", + "form_factor": "wide" + } + ], + "prefer_related_applications": false, + "related_applications": [ + { + "platform": "webapp", + "url": "./manifest.json" + } + ] +} diff --git a/one-time.html b/one-time.html index 7cc699d..8e2c039 100644 --- a/one-time.html +++ b/one-time.html @@ -4,8 +4,8 @@ permission.site (one-time) - - + + diff --git a/other-page.html b/other-page.html index d620b65..2dc3939 100644 --- a/other-page.html +++ b/other-page.html @@ -4,8 +4,8 @@ permission.site - - + + diff --git a/screenshot-1.png b/screenshot-1.png new file mode 100644 index 0000000..3ac2212 Binary files /dev/null and b/screenshot-1.png differ diff --git a/screenshot-2.png b/screenshot-2.png new file mode 100644 index 0000000..3ac2212 Binary files /dev/null and b/screenshot-2.png differ diff --git a/screenshot-3.png b/screenshot-3.png new file mode 100644 index 0000000..3ac2212 Binary files /dev/null and b/screenshot-3.png differ diff --git a/screenshot-4.png b/screenshot-4.png new file mode 100644 index 0000000..e4728a9 Binary files /dev/null and b/screenshot-4.png differ diff --git a/screenshot-5.png b/screenshot-5.png new file mode 100644 index 0000000..e4728a9 Binary files /dev/null and b/screenshot-5.png differ diff --git a/screenshot-6.png b/screenshot-6.png new file mode 100644 index 0000000..e4728a9 Binary files /dev/null and b/screenshot-6.png differ