- 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