mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-17 14:52:15 +00:00
Customize install prompt behavior
This commit is contained in:
@@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user