-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.js
31 lines (27 loc) · 1021 Bytes
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// window.addEventListener('beforeinstallprompt', saveBeforeInstallPromptEvent);
// function saveBeforeInstallPromptEvent(evt) {
// deferredInstallPrompt = evt;
// installButton.removeAttribute('hidden');
// deferredInstallPrompt.prompt();
// evt.srcElement.setAttribute('hidden', true);
// deferredInstallPrompt.userChoice
// .then((choice) => {
// if (choice.outcome === 'accepted') {
// console.log('User accepted the A2HS prompt', choice);
// } else {
// console.log('User dismissed the A2HS prompt', choice);
// }
// deferredInstallPrompt = null;
// });
// window.addEventListener('appinstalled', logAppInstalled);
// }
// function logAppInstalled(evt) {
// console.log('du-scales App was installed.', evt);
// }
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI notify the user they can add to home screen
showInstallPromotion();
});