20 lines
511 B
JavaScript
20 lines
511 B
JavaScript
// src/pwaInstall.js
|
|
let deferredPrompt = null;
|
|
|
|
window.addEventListener('beforeinstallprompt', (e) => {
|
|
e.preventDefault();
|
|
deferredPrompt = e;
|
|
console.log('PWA prompt ready');
|
|
});
|
|
|
|
export function promptInstall() {
|
|
if (deferredPrompt) {
|
|
deferredPrompt.prompt();
|
|
deferredPrompt.userChoice.then((choice) => {
|
|
console.log('Install outcome:', choice.outcome);
|
|
});
|
|
deferredPrompt = null;
|
|
} else {
|
|
alert('Prompt not ready. Scroll the map, click a filter, then try again.');
|
|
}
|
|
} |