mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Customize install prompt behavior
This commit is contained in:
parent
b788898134
commit
ef77ffb534
2 changed files with 21 additions and 0 deletions
|
@ -527,6 +527,17 @@ if ('serviceWorker' in navigator) {
|
|||
window.addEventListener('beforeinstallprompt', e => {
|
||||
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
return event.preventDefault();
|
||||
} else {
|
||||
const deferredPrompt = e;
|
||||
const btn = document.querySelector('#install')
|
||||
btn.hidden = false;
|
||||
btn.onclick = _ => {
|
||||
deferredPrompt.prompt();
|
||||
// Wait for the user to respond to the prompt
|
||||
deferredPrompt.userChoice.then((resp) => {
|
||||
console.log(JSON.stringify(resp));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue