From 800d4f5dd581a3d448e03aa7e0fdaee76ef4d526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Thu, 6 Jun 2024 21:15:36 +1000 Subject: [PATCH] Update explainer_same_domain.md: fix some nits (#826) Couple of nits --- WebInstall/explainer_same_domain.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/WebInstall/explainer_same_domain.md b/WebInstall/explainer_same_domain.md index 0ace9a5e..d4076674 100644 --- a/WebInstall/explainer_same_domain.md +++ b/WebInstall/explainer_same_domain.md @@ -37,20 +37,21 @@ Modern browsers have UX that enable users to *install* web content on their devi ### **Installing a web app from the current origin** The site can trigger its own installation. -The current way of doing this is with the `onbeforeinstallprompt`. This only works for browsers that support PWAs and prompting. The `navigator.install` method allows a imperative way to install web content, and works for UAs that prompt and don't prompt. +The current way of supporting installation is vai the `onbeforeinstallprompt` event, which only works in browsers that have a prompting UI affordace. + +The `navigator.install()` method allows a imperative way to install web content, and works for UAs that prompt and don't prompt: ```javascript /* tries to install the current domain */ const installApp = async () => { - if ('install' in navigator === false) return; // api not supported + if (!navigator.install) return; // api not supported try { - await navigator.install(); + await navigator.install(); } catch(err) { - switch(err.message){ + switch(err.name){ case 'AbortError': /* Operation was aborted*/ break; - } } };