Surface install-prompt failures instead of failing silently
This commit is contained in:
parent
6b247794db
commit
27a6b49b37
1 changed files with 14 additions and 5 deletions
|
|
@ -572,9 +572,18 @@ window.addEventListener('beforeinstallprompt', (e) => {
|
|||
|
||||
document.addEventListener('click', async (e) => {
|
||||
if (!e.target.closest('#btn-install')) return;
|
||||
if (!deferredInstall) return;
|
||||
deferredInstall.prompt();
|
||||
await deferredInstall.userChoice;
|
||||
if (!deferredInstall) {
|
||||
banner("No install prompt available — try Chrome's own menu (⋮ → Install app) instead.", true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deferredInstall.prompt();
|
||||
const choice = await deferredInstall.userChoice;
|
||||
if (choice.outcome !== 'accepted') banner(`Install ${choice.outcome}.`);
|
||||
} catch (err) {
|
||||
banner(`Install failed: ${err.message}`, true);
|
||||
} finally {
|
||||
deferredInstall = null;
|
||||
$('#btn-install').hidden = true;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue