-
Notifications
You must be signed in to change notification settings - Fork 173
Description
Hi folks, do you really like this idea, that a user-agent will "analyze" a website somehow and decide, if it is appropriate to show an install prompt? It can be disturbing, if the "analysis" is wrong. I also hate the fact, that a browser makes such decissions (browser manufacturers can show the prompt more often for websites, which pay them, nobody will ever find out). I think that the browser should be as "invisible" as possible, and each action should come from the user, or from the website with a users permit.
I am using the following code to be able to trigger an install prompt.
window.addEventListener("beforeinstallprompt", function(e){ e.preventDefault(); myEvent=e; });
if ("serviceWorker" in navigator) navigator.serviceWorker.register("sw.js", { scope: "./" });
// I call myEvent.prompt(); later, when user clicks Install
The problem I have is, that if both the website and the user want the site to be installed, the user-agent itself becomes an obstacle (by not dispatching "beforeinstallprompt"). What about replacing it all with this:
navigator.install();
It can throw an exception, when installing is not appropriate. If you think there is a risk of "attack" by calling it too often, we can deal with it the same way we deal with alert(...). Imagine if alert(...); worked only on Mondays and only between 12th and 37th minute of each hour. That is how I see the current draft now.