Yes, you can.
There is a beforeinstallprompt event that you can intercept and hold as long as you want (for example, until the user clicks your button).
There is a .prompt() function in the event, which you can call so that the prompt appears when you want it.
window.addEventListener ("beforeinstallprompt", ev => {
// Stop Chrome from asking _now_
ev.preventDefault ();
// Create your custom "add to home screen" button here if needed.
// Keep in mind that this event may be called multiple times,
// so avoid creating multiple buttons!
myCustomButton.onclick = () => ev.prompt ();
});
Kornel
source share